我尝试使用此路由解析模式,同时能够更改控制器范围内的变量。有没有办法做到这一点?
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();
}