我嘗試更新與API數據DOM,但我得到「$表沒有定義」這是我CTRL
app.controller('counter', ['$scope', 'factory', function ($scope, factory) {
factory.get(function (res) {
$scope.proizvedeno = res;
$scope.output = $scope.proizvedeno.total_energy_output;
$scope.countTo = $scope.output;
$scope.countFrom = 0;
$scope.$watch("output", $scope.countTo)
console.log($watch);
$scope.reCount = function() {
$scope.countFrom = Math.ceil(Math.random() * 300);
$scope.countTo = Math.ceil(Math.random() * 7000) - Math.ceil(Math.random() * 600);
}; }]);
我嘗試添加的手錶功能,全自動更新dom,但這不起作用。有人可以幫我請。
刪除console.log($ watch); – Thalaivar
您不會在任何可以記錄的地方創建名爲'$ watch'的變量。我建議你閱讀更多關於Angular手錶以及如何操作的信息。 – sdgluck
我從https://docs.angularjs.org/api/ng/type/$rootScope.Scope中讀到,我看不到Var $ watch在哪裏聲明。你可以幫我嗎? Thnx @thalaivar – Arter