我如何查看绑定到父控制器的变量?
function config($stateProvider) {
$stateProvider
.state('home', {
url: '/',
templateUrl: 'home.html',
controller: 'HomeController',
controllerAs: 'vm'
})
.state('home.child', {
url: '/child',
templateUrl: 'child.html',
controller: 'ChildController',
controllerAs: 'vm'
});
}
function HomeController($scope) {
this.title = 'Some Title';
}
function ChildController($scope) {
var vm = this;
$scope.$watch('vm.title', function(current, original) {
$log.info('title was %s', original);
$log.info('title is now %s', current);
});
}
watch-Function 无法识别父标题的更改..
谢谢!:)