的onLoad之间差异的角度NG-INIT [英] Difference between onLoad and ng-init in angular
问题描述
我学习的角度。我不明白是什么了varibale初始化的onLoad和NG-INT之间的差异。在这种范围内它创造这个变量。
I am learning angular. I don't understand what is difference between onLoad and ng-init for initialization of a varibale. In which scope it creates this variable.
例如
<ng-include onLoad="selectedReq=reqSelected" src="'partials/abc.html'"></ng-include>
或
<ng-include ng-init="selectedReq=reqSelected" src="partials/abc.html"></ng-include>
请也给我关于隔离范围有所了解。
Please also give me some idea about isolated scope.
推荐答案
NG-INIT
是可以放在里面的 DIV 指令code>的
跨度
的,什么的,而的onload
是一个属性特定于 NG-包括
指令其功能如同一个 NG-INIT
。要明白我的意思尝试类似:
ng-init
is a directive that can be placed inside div
's, span
's, whatever, whereas onload
is an attribute specific to the ng-include
directive that functions as an ng-init
. To see what I mean try something like:
<span onload="a = 1">{{ a }}</span>
<span ng-init="b = 2">{{ b }}</span>
您会看到只有第二个出现。
You'll see that only the second one shows up.
这是孤立的范围是不中典型从其父范围继承范围。在外行人的话来说,如果你有没有需要读取和写入父作用域随意,那么你使用的窗口小部件分离范围,以使小工具和小部件的容器可以自由支配自己的范围而不覆盖对方的属性。一个小部件
An isolated scope is a scope which does not prototypically inherit from its parent scope. In laymen's terms if you have a widget that doesn't need to read and write to the parent scope arbitrarily then you use an isolate scope on the widget so that the widget and widget container can freely use their scopes without overriding each other's properties.
这篇关于的onLoad之间差异的角度NG-INIT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!