ngForm
https://docs.angularjs.org/api/ng/directive/ngForm
Recipies
- Implement a delay on scope watch http://stackoverflow.com/questions/20397253/implement-a-delay-on-scope-watch
-
对于 SVG 的属性 xlink:href 需要动态指定值时,这样写比较好:
<use ng-href="{{ integration.Type | imageFilter:'#icon_puzzle-big' }}" xlink:href=""></use>
angular performance https://github.com/Pasvaz/bindonce https://github.com/angular/batarang http://stackoverflow.com/questions/25641714/angularjs-single-core-cpu-almost-100-cpu
https://medium.com/@kentcdodds/counting-angularjs-watchers-11c5134dc2ef#.qvc7qfus2
function getWatchers(root) { root = angular.element(root || document.documentElement); var watcherCount = 0; function getElemWatchers(element) { var isolateWatchers = getWatchersFromScope(element.data().$isolateScope); var scopeWatchers = getWatchersFromScope(element.data().$scope); var watchers = scopeWatchers.concat(isolateWatchers); angular.forEach(element.children(), function (childElement) { watchers = watchers.concat(getElemWatchers(angular.element(childElement))); }); return watchers; } function getWatchersFromScope(scope) { if (scope) { return scope.$$watchers || []; } else { return []; } } return getElemWatchers(root); }
angular input number allowInvalid
使用 <input type="number" ng-model="v" min=1>
时,如果在 UI 上输入 0,那么 v
的值将会是 undefined
。
这是因为输入值不满足 min=1
的限制要求。要突破这个限制,可以加上 ng-model-options="{ allowInvalid: true }"
ui-router
https://ui-router.github.io/ng1/docs/1.0.0-alpha.5
http://stackoverflow.com/questions/17001589/directing-the-user-to-a-child-state-when-they-are-transitioning-to-its-parent-st
onBefore
的 callback 必须接收 \(transition\)
依赖才能正常工作, 使用 \(transition\).get()
可以获得当前 state, 使用 \(transition\).params()
可以获得对应的路由参数
手动路由跳转时如何忽略参数等 https://github.com/angular-ui/ui-router/issues/613
禁止将参数解析成 Array 类型 https://ui-router.github.io/ng1/docs/latest/interfaces/params.paramdeclaration.html#array
Angular 4
ngOnInit
called twice
``` In my @NgModule decorator’s metadata object ,I was passing ‘child component’ in the bootstap property along with ‘parent component’. Passing the child components in bootstap property was resetting my child components properties and making OnInit() fired twice. ``` See: https://github.com/angular/angular/issues/6782#issuecomment-267366857
trigger ngClick event programmatically http://stackoverflow.com/questions/22447374/how-to-trigger-ng-click-angularjs-programmatically