【发布时间】:2014-10-08 00:26:16
【问题描述】:
我正在尝试在 $routeProvider 路由上使用 controllerAs 属性,但没有成功。
这里是示例代码:
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';
});
不确定这是错误还是我做错了什么,This is a plnkr that demonstrates the issue
【问题讨论】:
标签: angularjs angularjs-routing