[AngularJS] ng-if to enable ng-controller 利用ng-if 驅動 ng-controller

摘要:[AngularJS] ng-if to enable ng-controller 利用ng-if 驅動 ng-controller

因為 ng-show/ng-hide 是將 DOM 做display 切換
實際上DOM已經長出來了
但 ng-if 是會真的切換DOM

所以當 某個controller 綁在 ng-if 上面的時候
就會在 顯示時才載入 ng-controller 的功能

 

See the Pen ng-if to enable ng-controller by yi-chan (@yi-chan-chiang) on CodePen.