Is there something similar to "KO.mapping.fromJS" in AngularJS?

I wanted to add some new computed property to the complex json object returned from the REST service. This can be easily achieved using the KnockoutJS Mapping pluggin.

But this time I decided to go for AngularJS. Are there any modules / pluggins similar to displaying a plugin knockout?

my PROBLEM looks like this:

JSON Returning from the server is something like:

{ id:2, name: 'jhon', relatives:[ {id:1,name:'linda', score:{A:10,B:33,C:78} }, {id:2,name:'joseph', score:{A:20,B:53,C:68} }, {id:3, name:'keith', score:{A:40,B:83,C:30} } ] } 

in the above json object, I want to attach some computed property to each object within the collection of "relatives" based on the rating that each relative has.

+4
source share
2 answers

Try using

 angular.extend($scope, data); 

I am also starting to use Angular starting with Knockout and Durandal :) I hope this may work for you. Data should be available in your view ($ scope) directly.

Edit: See thread .

+2
source

Basically in angular there is nothing like observable variables.

AngularJS does observation separately from the volume itself. To make a map from Json in AngularJS, you can use angular.fromJson to bind data from Json.

To add fields to the scope, you can also use angular.extend .

But in any case, adding a calculated field is what you need to do yourself, for this you can try using the viewing methods: $ scope. , $ scope.watchGroup , watchCollection .

+1
source

All Articles