我已经从angular.io开始学习Angular2。我从本教程中学习了一个示例。错误:在ES5中没有服务提供商Angular2
组件:
function FriendService(){
this.friendList = ['Wam','Pam','Sam','Cam'];
}
function PersonalInfo (friends){
this.myName="Jam";
}
PersonalInfo.annotations = [
new angular.ComponentAnnotation({
selector : 'app',
injectables :[FriendService]
}),
new angular.ViewAnnotation({
template:'<h3>{{myName}} Friend\'s</h3>'
})
];
PersonalInfo.parameters =[[FriendService]];
document.addEventListener('DOMContentLoaded', function(){
angular.bootstrap(PersonalInfo);
})
查看:
<body>
<app></app>
</body>
这里,我已经注入FriendService的成分,也传递参数给PersonalInfo组件。但它给错误:
没有FriendService的提供商! (PersonalInfo - > FriendService)
有人对这个错误有什么想法吗?