我有以下代码:
状态(为了简单起见,让我们简称)
.state('foo', {
url: '/foo',
templateUrl: 'path/to/template.html',
controller:'fooCtrl',
})
控制器
controller = function($scope){
// not the actual code
$scope.barCount
}
模板.html
<div>
<span>{{ barCount }}</span> // this is updating properly
</div>
其他 html 部分
<div ng-controller="fooCtrl">
<span>{{ barCount }}</span> // this is **NOT** updating properly
</div>
我的控制器上有一个scope
变量。2 路绑定在与控制器一起声明的模板上运行良好。但不是在我使用.state
ng-controller
这是某种错误吗?还是我错过了什么?谢谢。