AngularJS组件进样器模块开关

时间:2016-09-30 19:42:45

标签: angularjs

我尝试编写我的第一个组件。实际上,我重构了我之前的一个网页,以使用更多的AngularJS功能。 我使用AngularJS 1.5.8

老实说,我总是遇到以下注入错误: http://screencast.com/t/xpyVqSjwUxU

这是我的组件代码: http://screencast.com/t/zMaED5ZfZ

当我在index.html中添加带脚本标记的component.js文件时,出现了错误。

任何想法,我会变得多么糟糕?我阅读了组件angularjs文档,但没有找到错误。

2 个答案:

答案 0 :(得分:0)

尝试将返回值{ templateUrl: ..., controller..., etc }放入.component()函数。

angular
  .module('Profile')
  .component('UpdatePasswordComponent', {
    templateUrl: '/modules/profile/update-password/update-password.component.html',
    controller: UpdatePasswordController,
    controllerAs: 'vm'
  });

答案 1 :(得分:0)

另一种选择可能只是改变这一行

.component('UpdatePasswordComponent', Component)

.component('UpdatePasswordComponent', Component())

实际上会调用并返回该对象,但我对此不感兴趣。