jeudi 26 janvier 2017

Accessing to a function's variable from a controller AngularJS

New to AngularJS I'm getting completely mad to do a basic move.

I have a function retrieving a number from the HTML. I want to use this number in my controller, no more.

<button  onclick="mag(004)">004</button>

JS:

var app = angular.module('webStatistics', [], function (){
})

function mag(store) {
    console.log(store);
}

app.controller('004', function ($scope, $http){
        var mag = $scope.store;
        console.log(mag)

  $http.get('../app/sources/stats/004/122.json').success(function(data) {
         $scope.variables = data;
        });
});;

My purpose is to put this number in the url given to the $http service.




Aucun commentaire:

Enregistrer un commentaire