ui-router状态:
$stateProvider .state('dashboard',{ url: '/dashboard',templateUrl: 'app/dashboard/dashboard.html',controller: 'DashboardController as vm' });
在DashboardController中我有:
var vm = this; vm.title = 'Dashboard';
在dashboard.html模板中:
{{vm.title}}
为什么结果显示“{{vm.title}}”而不是绑定到控制器中的值?
配置状态时有一个controllerAs设置.
$stateProvider .state('dashboard',controller: 'DashboardController',controllerAs: 'vm' });