我试图controllerAs在$routeProvider路线上使用该属性,但没有任何成功.
以下是示例代码:
var app = angular.module('app', ['ngRoute']);
app.config(['$routeProvider', '$locationProvider',
function($routeProvider) {
$routeProvider
.when('/', {
template:'<div>This should be visible:{{ ctrl.one }}</div><div>This should not:{{ one }}</div>',
controller: 'Ctrl',
controllerAs: 'ctrl',
});
}]);
app.controller('Ctrl', function($scope) {
$scope.one = 'actual';
});
Run Code Online (Sandbox Code Playgroud)
不确定这是一个错误还是我做错了什么,这是一个展示问题的plnkr