?? ??? ?? ? ??? ??? ?????.
????js
????? undefine? ??????
?? ?? js ??? ??? scope:{}
?? ?????. ??? ???? ??? ?????? ?, OutSide myDirective: wow! that is cool
??? ? ??? ????
認(rèn)證0級(jí)講師
???
??, ??? ? ??? ??? ?? ??? ????. ???? ??
? ???? ??? ??? ???
? ????? ???? ??? ????. scope
是影響它的template
的作用域,這里并不是。
<p my-directive ng-init="myProperty='wow! that is cool'">
Inside myDirective : {{myProperty}}
</p>
這里undefined的原因是因?yàn)閏ontroller在ng-init之前執(zhí)行了。可以用用延時(shí)或者$watch
???
$watch
? ???? ????? ? ??????
?????,,, ??? ???? ?? ??? ????? ??? ??, ? scope:{}
時(shí),Inside myDirective : {{myProperty}}
這個(gè)表達(dá)式還是屬于外面那個(gè)作用域是不是?而此時(shí)template里面并沒有設(shè)定,,,所以隔離作用域就沒有起作用,我這樣理解對嗎?
還有一個(gè)問題,既然這樣,,,那為什么如果把scope設(shè)定為scope:true
? ?? ??? ??? ???? ?? ???????.
? ? ????? ? ???? ?????~~