[AngualrJS] ng-strict-di

Posted Answer1215

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[AngualrJS] ng-strict-di相关的知识,希望对你有一定的参考价值。

In Angular 1.5 introduces "compoment" syntax. But ng-annotate doesn‘t understand ".compoment" syntax, that‘s why in min version, the code doesn‘t work.

 

so use "ng-strict-di" directive, it tell AngualrJS when compile time to check whether the dependciy injection is working or not.

  <body ng-app="app" ng-strict-di ng-cloak>

    <app>
      Loading...
    </app>

    <script src="bundle.js"></script>
  </body>

 

Then we when use compoment, if we don‘t add ‘ngInject‘, then it will block the compiler, so everytime we use component, we need to add:

class CategoriesController {
  constructor(CategoriesModel) {
    ‘ngInject‘;

    CategoriesModel.getCategories()
      .then(categories => this.categories = categories);
  }
}

export default CategoriesController;

 

以上是关于[AngualrJS] ng-strict-di的主要内容,如果未能解决你的问题,请参考以下文章

看angualrjs源码中怎么判断所属的类型

angualrjs 总结 随记

AngualrJS中制作一个有关菜单的Directive

angualrjs2教程

angualrjs 配置超时时间

angualrjs- $http简单应用解析