ui-router State:$stateProvider .state('dashboard', { url: '/dashboard', templateUrl: 'app/dashboard/dashboard.html', controller: 'DashboardController as vm' });In DashboardController I have:var vm = this;vm.title = 'Dashboard';And in dashboard.html template:{{vm.title}}Why the result is showing "{{vm.title}}" instead of bind to it's value in controller? 解决方案 There's a controllerAs setting when you configure the state.$stateProvider .state('dashboard', { url: '/dashboard', templateUrl: 'app/dashboard/dashboard.html', controller: 'DashboardController', controllerAs: 'vm' });https://github.com/angular-ui/ui-router/wiki 这篇关于带有 ControllerAs 绑定的 ui-router的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-22 02:07