javascript - How to refresh data-ng-init using directive -



javascript - How to refresh data-ng-init using directive -

how refresh variable assigned in data-ng-init whenever source info changes.

i know how controller. there anyway html using directive.

below sample demo have done, see auto , bike section when click "add car" listing , counts changed i'm using direct source

when click "add bike", bikedata not refreshed, holds initial json value only.

data-ng-init="bikedata = (sorted | filter: { type: 'bike' }:true)"

demo

that's because bikedata isn't refreshed after. either need watch changes on sorted object , update bikedata. or can slap same look have in data-ng-init ng-click directive. see demo:

http://jsfiddle.net/tomalex0/9jxqk/1/

another alternative rid of data-ng-init , bind ng-repeat sorted object cars. example:

<ul ng-repeat="item in sorted | filter: { type: 'bike' }:true">

javascript angularjs

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -