路径解析模式的角度范围问题

时间:2016-10-05 21:56:37

标签: angularjs

我尝试使用此路由解析模式,同时能够更改控制器范围内的变量。有没有办法做到这一点?

app.config(function ($locationProvider, $routeProvider) {
  $routeProvider.when("/", {
        templateUrl:"views/home.html",
        controller: "appCtrl",
        resolve: {
            loadSite: appCtrl.loadSite
        }
  });
});

var appCtrl = app.controller('appCtrl', ['$scope', function($scope) {

    $scope.hidePoster = false; // default

    /*
    $scope.hidePoster = true; // worked fine when I applied it here
    $scope.$apply();
    */

}]);

appCtrl.loadSite = function () {
    $scope.hidePoster = true; // $scope is not defined
    $scope.$apply();
}

0 个答案:

没有答案