使用select绑定和刷新范围变量

时间:2016-01-20 21:56:37

标签: javascript angularjs angularjs-directive angularjs-scope

我正在使用我的api进行一些工作,发现我在同一个脚本中使用的范围变量没有更新:

<div ng-app="myApp" ng-controller="customersCtrl">
<select name="equipo" ng-model="selector">
    <option value="0">0</option>
    <option value="1">1</option>
    <option value="2">2</option>
</select>
selector: {{selector}}
    url: {{url}}
<div>
  <p ng-repeat="j in myData">
    {{ j.nombre }}
  </p>
</div>

<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
    $scope.selector = "1";
    $scope.url = "http://127.0.0.1:8080/api/equipos/"+$scope.selector+"/jugadores";

  $http.get("http://127.0.0.1:8080/api/equipos/"+$scope.selector+"/jugadores").then(function (response) {
      $scope.myData = response.data;
      console.log($scope.myData);});
});
</script>

当我更改输入中的选项时,url($ scope.url)不会更改。我缺少的任何提示或事物?

0 个答案:

没有答案