If you are not using a .(dot) in your AngularJS models you are doing it wrong? -


i remember seeing famous quote video on angularjs saying should using . (dot) in models.

well trying follow have

   var item = {}    item.title = "easy access support";    item.available = true;    item.price = 31.67; 

so works great in view

  {{ item.title }}   {{ item.available }} 

i using dot think good.

but have properties don't consider part of model maybe wrong. example have property use enable or disable button using ng-disable, have entered using dot format. entered so

 $scope.disablebutton = true; 

and use

 ng-disable="disablebutton"...... 

should make part of model "item" ? or create js object can hold property using dot ?

anybody know if acceptable or should doing (even these simple properties) .dot ??

thanks

the "there should dot in model" refers ngmodel. directive two-way binding. if two-way bind primitive (such boolean in case), setter set on current scope rather scope on defined, can cause headache when have large user-interface lot of child scopes. it not refer other directives such ngdisable. see this explanation more details on specific issue.

sample scenario: parent scope $scope.foo = "bar", , child scope <input type="text" data-ng-model="foo">. display bar initially, once user changes value, foo created on child scope , binding read , write value. parent's foo remain bar. hope summarises well.

so ngmodel purposes, might have create object work around such binding issues, other directive should have regular, logical grouping.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -