Reusing Form snippets in AngularJS -


what best way go creating small bit of html form elements , reusing snippet multiple times in form, different models?

e.g. inputs firstname, lastname, streetaddress, city, state, zip student, parent, pointofcontact

if hard-coding model , inputs, have like:

<input name="student.firstname" ng-model="student.firstname" > <input name="student.lastname" ng-model="student.lastname" > <input name="parent.firstname" ng-model="parent.firstname" > <input name="parent.lastname" ng-model="parent.lastname" > <input name="pointofcontact.firstname" ng-model="pointofcontact.firstname" > <input name="pointofcontact.lastname" ng-model="pointofcontact.lastname" > 

as angularjs noob, i'm not sure how $modelprefix.firstname

template ?

<input name="$modelprefix.firstname" ng-model="$modelprefix.firstname" > <input name="$modelprefix.lastname" ng-model="$modelprefix.lastname" > 

wrap each of reusable html components in angular directive. allow reuse html while still passing in different models each.

this technique (and others) explained in videos posted on http://egghead.io/ purposes pay close attention videos 10,11,14 , 15.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -