Angularjs的一些建议用法

参考:http://jishu.zol.com.cn/201057.htmlhtml

1)避免UI闪烁spa

 Angular的自动数据绑定功能是亮点,然而,他的另外一面是:在Angular初始化以前,页面中可能会给用户呈现出没有解析的表达式。当DOM准备就绪,Angular计算并替换相应的值。这样就会致使出现一个丑陋的闪烁效果。code


<p>{{ phone.snippet }}</p>

改成orm

<p ng-bind="phone.snippet"></p>

2)依赖注入htm

module.service('myservice', function($http, $q) {
// This breaks when minified
});

改成ip

module.service('myservice', [ '$http', '$q', function($http, $q) {
// Using the array syntax to declare dependencies works with minification<b>!</b>
}]);
相关文章
相关标签/搜索