angularjs - Why is controller created twice? -


consider following angularjs app:

method addpane() pushes pane controller's pane list, panecount() returns length. after creating 3 panes, accessing method panecount() binding {{panecount()}} , directly in test: scope.panecount() returns 0.

it appears angularjs creates 2 instances of controller - 1 accessible controller methods, scope's. know why there's need of creating 2 instances? there way access same properties both controller , scope methods?

the problem controller definition of yours! defined scope twice. once in controller , once in directive definition of tabs directive. directive definition overrides scope of controller , therefore count not correct.

// scope: {}, not necessary because defined in controller ctrl

hope helps :)


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -