I am using AngularJS for creating web app. This is the link which present my full code (example with b.0001.html). AngularJS example
How can I get value ($scope.confirmed in $scope.change function) in controller when user select option data from form? The main problem is that everything works fine if I create one file, but with separated file it won't work, that means if you have one file which include another file with form (using routing in AngularJS).
The form is, which I include in main file with routing mechanism
< select ng-model="confirmed" ng-change="change()" id="ng-change-example1">
< option > 11 < /option>
< option > 12 < /option>
< option > 13 < /option>
< option > 14 < /option>
< input type="checkbox" ng-model="confirmed" id="ng-change-example2" />
< label for="ng-change-example2">Confirmed</label><br />
< tt>debug = {{confirmed}}</tt><br/>
< tt>counter = {{counter}}</tt><br/>
<tt>onchange_var_url = {{myurl}}</tt><br/>
< ul>
< li ng-repeat="x in names">
{{ x.Name + ', ' + x.Country }}
< /li>
< /ul>
Variable myurl should get value from user option select, but it doesn't. This is controler
angular.module('changeExample', [])
.controller('ExampleController', ['$scope','$http', function($scope,$http) {
$scope.counter = 0;
$scope.myurl = 'result from confirmed on change on load: ' + $scope.confirmed;
$scope.change = function() {
$scope.counter++;
$scope.myurl = 'result from confirmed on change: ' + $scope.confirmed;
$http.get("angularjs-data/json-data-0001.json?var=" + $scope.confirmed)
.success(function (response) {
$scope.names = response.records;
});
};
}]);
Aucun commentaire:
Enregistrer un commentaire