我正在用angularjs做一个简单的cms,但是我的指令有问题。无法更新angularjs指令的内容
我无法更新指令的内容。我没有收到任何错误,但内容未更新。
这里是我的代码:
app.js
var postApp = angular.module('adminApp', [
'ngRoute', 'angular-ladda'
]);
postApp.config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider) {
$routeProvider.
when('/posts', {
templateUrl: '/ngpartials/admin/blog/index.html',
controller: 'PostListCtrl'
}).
otherwise({
redirectTo: '/posts'
});
}
]);
postApp.controller('PostListCtrl', function($scope, $http){
$scope.showLoading = false;
$scope.items = [];
$scope.name = 'Mike';
});
postApp.directive('helloWorld', function() {
return {
scope: {
name: "="
},
restrict: 'E',
template: '<h3>Hello World!!: {{ name }}</h3>'
};
});
模板:
<div ng-controller="PostListCtrl" class="ui grid container">
<h1 class="ui header"><a href="#/posts/">Posts</a></h1>
<hello-world></hello-world>
<div ng-view></div>
</div>
结果:
的Hello World!:
你必须具有嵌套毫无reason..please在我的答案不这样做that..look同一控制不好的设计 –