我有一个AngularJS测试应用程序,它基于链接路径动态地使用AngularUI加载模态窗口。我的模态窗口加载,但模板控制器中没有$ scope变量被模板访问,我不能从模板触发任何$ scope函数。
这里的$ routeProvider:
.config(function($routeProvider) {
$routeProvider
.when('/page/:name', {
templateUrl : 'modalContainer',
controller : 'ModalCtrl'
})
})
和这里的控制器:
.controller('ModalCtrl',['$scope', '$modal', '$route', function($scope, $modal, $route) {
console.log("hello I am the ModalCtrl") //This console log runs
var modalInstance = $modal.open({
templateUrl : 'modal.html',
});
$scope.activity = $route.current.pathParams.name;
console.log($scope.activity) //This console log runs & shows the correct value,
// but the $scope variable is not visible in the template
//Modal controls
$scope.close = function() {
console.log("close!") //This does not run.
modalInstance.close();
};
}]);
我想,我创造了模态窗口的范围不正确不知何故,有人可以看到问题?