Home in Angular, passing a value from resolve to the controller
Reply: 0

in Angular, passing a value from resolve to the controller

uniXVanXcel
1#
uniXVanXcel Published in 2017-11-14 16:09:15Z

I am trying to pass this variable to the controller and then display on the screen. I am not sure why I am getting undefined for that value. I went tru the similar SO questions and it seems iam doing it right.

.state({
                name: "test",
                url: "/testURL",
                views: {
                    'testView': {
                        template: '<div><span>{{testvariable}} </span></div>',
                        controller: "testController",
                        resolve: {
                            testString: function () {
                                debugger;
                                return 'from Resolve';
                            }
                        }
                    }
                },
            })
      })

      app.controller("testController", ["$scope", "$state",

        function ($scope, $state, testString) {
            console.log("getting from resolve ", testString)
            $scope.testvariable = function () {
                console.log("getting from resolve ", testString)
                return testString;
            }
            $scope.testvariable();

        }
      ])
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.239516 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO