Read More: http://www.linkplugapp.com/a/953215

https://docs.google.com/document/d/1XXMvReO8-Awi1EZXAXS4PzDzdNvV6pGcuaF4Q9821Es/pub

angular-hint helps us writing better Angular code and makes finding very common mistakes in our code base easier. For example, did it ever happen to you, that you developed your Angular app, you grabbed a module from somewhere, then you started using the directives that the module comes with, and no matter how much you followed the usage instructions, it simply didn’t work. And after one hour of debugging you found out that you forgot to add the module dependency to your application. Yikes!

These modules are:

Install and using angular-hint

npm install angular-hint

Once it’s installed, we can embed the source in our application right after Angular itself like this:

<script type="path/to/angular/angular.js"></script>
<script type="path/to/angular-hint/hint.js"></script>

Next, we apply the ng-hint directive in order to actually use the angular-hintmodule:

<body ng-app="myApp" ng-hint>
</body>

By defaultng-hint injects all the mentioned hint modules.

However, if we don’t want to get controller related hints, but are interested in DOM related hints, we can restrict the use of hint modules by using the ng-hint-include directive instead.

The following code only injects angular-hint-dom:

<body ng-app="myApp" ng-hint-include="dom">
</body>

We can even define more than just one hint module if needed:

<body ng-app="myApp" ng-hint-include="dom directives">
</body>

Module hints

If you declared an module:

angular.module('myAppDependency', []);

but forgot to include into your main app:

angular.module('myApp', []);

Now, instead of fiddling around for an hour to find out why myAppDependency’s directives aren’t picked up, angular-hint is telling us that we might missed something. Simply open your browsers console and you should see something like this:

Angular Hint: Modules
Module "myAppDependency" was created but never loaded.

Controller hints

One of these best practices is, when naming controllers, to suffix them with Controller instead of using short names like Ctrlangular-hint helps with that too. Let’s take a look what happens when we define a controller with a name that doesn’t have this suffix:

angular.module('myApp', []).controller('AppCtrl', function () {

});

Having a controller registered like this, angular-hint gives us the following warning:

Angular Hint: Controllers
The best practice is to name controllers ending with 'Controller'.
Check the name of 'AppCtrl'

Directive hints

Example where error might happens:

<ul>
<li ng-repaet="i in [1,2,3,4]">
<!-- more dom goes here -->
</li>
</ul>

However, when angular-hint is activated, we get the following very useful warning:

Angular Hint: Directives
There was an AngularJS error in LI element.
Found incorrect attribute "ng-repaet" try "ng-repeat"

[AngularJS] Angular 1.3 Anuglar hint的更多相关文章

  1. [Angularjs]angular ng-repeat与js特效加载先后导致的问题

    写在前面 最近在项目中遇到这样的一个前端的bug,在ng-repeat中绑定的图片,有一个晃动的特效,在手机端浏览的时候,图片有时候会正常展示,有时就展示不出来.当时猜测是因为angularjs与特效 ...

  2. [AngularJS] Angular 1.3 ngMessages with ngAnimate

    Note: Can use $dirty to check whether user has intracted with the form: https://docs.angularjs.org/a ...

  3. [AngularJS] Angular 1.3 $submitted for Form in Angular

    AngularJS 1.3 add $submitted for form, so you can use  $submitted  to track whether the submit event ...

  4. [AngularJS] Angular 1.3 ng-model-options - getterSetter

    getterSetter:  boolean value which determines whether or not to treat functions bound to ngModel as ...

  5. [AngularJS] Angular 1.3: ng-model-options updateOn, debounce

    <!DOCTYPE html> <html ng-app="app"> <head lang="en" > <meta ...

  6. AngularJs angular.identity和angular.noop详解

    angular.identity 函数返回本身的第一个参数.这个函数一般用于函数风格. ----------以上是官网对该接口的说明,只能说这个文档写得也太二,让人完全看不懂.要理解它的用途,可直接看 ...

  7. AngularJs angular.Module模块接口配置

    angular.Module Angular模块配置接口. 方法: provider(name,providerType); name:服务名称. providerType:创建一个服务的实例的构造函 ...

  8. AngularJs Angular数据类型判断

    angular.isArray 判断括号内的值是否为数组. 格式:angular.isArray(value); value: 被判断是否为数组的值. ------------------------ ...

  9. AngularJs angular.injector、angular.module

    angular.injector 创建一个injector对象, 调用injector对象的方法可用于获取服务以及依赖注入. 格式:angular.injector(modules); modules ...

随机推荐

  1. zimg 启动命令

    cd zimgcd bin ./zimg conf/zimg.lua

  2. eclipse JavaEE的配置

    Eclipse IDE for Java EE Developers(win32) 下载地址:http://mirror.bjtu.edu.cn/eclipse/technology/epp/down ...

  3. MAC OS 10.10.5虚拟机免费下载(可安装Xcode7)

    MAC OS 10.10.5虚拟机免费下载(可安装Xcode7)   MAC OS 10.10.5虚拟机免费(可安装Xcode7)下载地址:链接: http://pan.baidu.com/s/1dD ...

  4. React Native 系列(二)

    前言 本系列是基于React Native版本号0.44.3写的,最初学习React Native的时候,完全没有接触过React和JS,本文的目的是为了给那些JS和React小白提供一个快速入门,让 ...

  5. PHP函数usort是咋回事?还能当后门?

    开始 详情看这:https://www.leavesongs.com/PHP/bypass-eval-length-restrict.html 原谅我见识短,没用过usort函数 上面连接的文章中,发 ...

  6. Failed to read auto-increment value from storage engine错误的处理方法

    在进行数据的插入时,系统提示Failed to read auto-increment value from storage engine(从存储引擎读取自增字段失败)错误,经查阅资料,解决方法如下: ...

  7. VK Cup 2016 - Qualification Round 1 (Russian-Speaking Only, for VK Cup teams) C. Promocodes with Mistakes 水题

    C. Promocodes with Mistakes 题目连接: http://www.codeforces.com/contest/637/problem/C Description During ...

  8. 【弱省胡策】Round #0 Flower Dance DP

    Flower Dance Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://162.105.80.126/contest/%E3%80%90%E ...

  9. 2015 UESTC 搜索专题J题 全都是秋实大哥 kmp

    全都是秋实大哥 Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/contest/show/61 Desc ...

  10. Jackson工具类使用及配置指南、高性能配置(转)

    Jackson使用工具类 通常,我们对JSON格式的数据,只会进行解析和封装两种,也就是JSON字符串--->Java对象以及Java对象--->JSON字符串. public class ...