jeudi 23 juillet 2015

In AngularJS, after clicking a button, how to retrieve one of the two Json files and put it in $scope variable?

For example,

There two JSON files:

Json file #1: [{colorname:blue},{colorname:blue}]

Json file #2: [{colorname:red},{colorname:red}]

In controller, there is a variable $scope.color

In html, there are two buttons, one is called "colorblue". the other one is called "colorred".

What I want to do is: When clicking button "colorblue", the $scope.color variable equals to Json file #1; When clicking button "colorred", the $scope.color variable equals to Json file #2.

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire