0
我点名的观点:UI路由器命名视图和NG-控制器
.state('home', {
url: '/',
views: {
'' : {
templateUrl: '/layouts/main.html',
controller: ['$rootScope', function($rootScope) {
$rootScope.css.background = "#ebeced";
}]
},
'[email protected]': { templateUrl: '/templates/nav.html' },
'[email protected]': { templateUrl: '/home/menu.html'},
'[email protected]': { templateUrl: '/templates/feed.html' },
'[email protected]': { templateUrl: '/home/footer.html' }
}
})
和main.html
看起来是这样的(注意,NG-控制器):
<div ng-controller="baseCtrl">
<div ui-view="nav"></div>
<div class="wrapper">
<div id="menu">
<div ui-view="menu"></div>
</div>
<div ui-view="main"></div>
<div id="footer">
<div ui-view="footer"></div>
</div>
</div>
</div>
我baseCtrl
是不承认ng-model
值在ui-view
中的任何一个文本框中。
<input type="text" ng-model="url" ng-blur="addUrl()" />
和baseCtrl
:
$scope.url = ""; //required or get error about not being defined
$scope.addUrl = function() {
console.log($scope.url); //nothing???
}
上午我做一个愚蠢的错误地方?
UPDATE: 我想我已经解决了这个问题 - 我需要定义baseCtrl
作为控制器每个视图了。
你应该写答案,并接受它:-) – pietro909