我仍在学习角度,并遇到了这个问题:
服务定义:
app.service('headService', function($window) {
this.display = 0;
return {
setTitle: function (newTitle) { $window.document.title = newTitle; },
setDisplay: function (value) { this.display = value;},
getDisplay: function () {
if(this.display===undefined){
this.display = 1;
}
return this.display
}
};
})
控制器定义:
app.controller('startController', function(headService) {
headService.setTitle('by app 3');
this.isVisible = function () {
if(headService.getDisplay()===1){
return true;
} else {
return false;
}
}
});
指令实施
app.directive("startDirective", function(headService) {
return {
restrict : "E",
templateUrl: 'app/templates/start.html',
controller: 'startController'
};
});
现在我想显示方法this.isVisible返回true
<div layout="column" flex>
<start-directive></start-directive>
<content-directive></content-directive>
<login-directive></login-directive>
</div>
包括
<body ng-controller="bodyController">
<application-directive layout="row" flex></application-directive>
</body>
但是我无法让它运转起来。任何提示?