Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

ng-init is not live, need way to bind 'local variables' #955

Closed
mprobst opened this issue May 14, 2012 · 5 comments
Closed

ng-init is not live, need way to bind 'local variables' #955

mprobst opened this issue May 14, 2012 · 5 comments

Comments

@mprobst
Copy link
Contributor

mprobst commented May 14, 2012

ng-init is not live, it'll only bind once a new scope is created: http://jsfiddle.net/mprobst/gVeS3/

The documentation on ng-init spells this out, but in terms newbies will have a hard time to understand. Maybe this could be clarified, preferably with a big warning sign?

In any case, Angular has directives as a method of modularization and ng-include. Directives have a relatively high overhead to set up, so ng-include seems the simpler alternative. But to effectively modularize your templates, you need to set up the scope for an ng-include, i.e. bind certain properties to what the included template expects. The first thing that comes to mind is ng-init, but that does not work due to not being live.

As far as I can tell there's no way in Angular to set up the scope for an included template. Could we have that? Is it possible to write an ng-include that takes additional attributes for its scope, or just a generic ng-init that is live?

@mhevery
Copy link
Contributor

mhevery commented May 15, 2012

works as intended, and we are planning on deleting ng-bind

@mhevery mhevery closed this as completed May 15, 2012
@matthew-b-payne
Copy link

^^^ What a horrible response!!

@nilskp
Copy link

nilskp commented Mar 27, 2013

Deleting ng-bind??? Why, and what would take it's place?

@klebba
Copy link

klebba commented Aug 1, 2013

@mhevery I'm confused; what would be the best way to implement a live ng-init equivalent? Directive?

@vizo
Copy link

vizo commented Oct 22, 2013

👍 .. i want to know the same ..

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants