javascript - Angularjs: how load model in lazy mode -


i want load data in lazy mode. in particular, suppose have object one:

$scope.person = {    name: 'stefano',    surname: 'rossi',    address: 'orange road',    city: {        clazz: 'foo.bar.city',       id: 5,        lazy: true    } } 

with angular can bind first 3 properties html tag without problem.

<input ng-model="person.name"> <input ng-model="person.surname"> <input ng-model="person.address"> 

and works well.

but suppose want add decode of city, possible interact ngbinding or ngmodel test if object lazy, promise real value (i think $http service )

i try extend ngmodel not have correct $scope...

https://jsfiddle.net/qq4gqn6t/13/

anybody knows how interact ngmodel o ngbinding?

thanks in advance

due two-way data binding models lazy loaded once mounted on view. here rough example loading model upon event giving ability make additional changes.

$scope.loadlater = function() {     $scope.person = {       name: 'stefano',       surname: 'rossi',       address: 'orange road',       city: {         clazz: 'foo.bar.city',         id: 5,         lazy: true       }     }   } 

https://jsfiddle.net/qq4gqn6t/14/


Comments