$ scope.value不会随视图一起更新

时间:2017-10-18 22:31:44

标签: angularjs slider

我一直在努力,一无所获。我希望使用我的服务从值创建简单的圆形滑块,但$ scope.value没有更新我的视图。看看我的演示:

https://jsfiddle.net/gh42tqxs/11/

<div ng-app="mainApp">
  <div ng-controller="FooController">
     <ui-knob  value="value" options="options" knob-format  data-note="{{note}}"></ui-knob>
  </div>
</div> 

var app = angular.module("mainApp",['ui.knob']);

app.service('Service', function ($http, $q) {
    this.Get = function (premiereId) {
        var deferred = $q.defer();
        var req = {
            method: 'GET',
            url: 'https://api.myjson.com/bins/63xhr',
            headers: {
                'Content-Type': 'application/json'
            }
        }
        $http(req).then(function (response) {
            if (response.status == 200) {
                deferred.resolve(response.data);
            }
            else {
                deferred.reject(response.data);
            }
        }, function (error) {
            deferred.reject(error.data);
        });
        return deferred.promise;
    }
})

app.controller("FooController", function (Service, $timeout, $scope) {
        function test() {
        Service.Get().then(function (response) {
                    $timeout(function () {
                console.log(response);
                $scope.value = response.Number;
                $scope.options.min = response.NumberMin;
                $scope.options.max = response.NumberMax;
            }, 1000);
      })
    }
    test();
});

动画未启动,我们从最小值开始,而不是从$ scope.value开始。

ng knob == jquery knob slider

如何解决?请帮帮我。

0 个答案:

没有答案