javascript - angularjs, Scope not updating across functions - with ngTouch -



javascript - angularjs, Scope not updating across functions - with ngTouch -

i have controller such:

$scope.myvar = 0; $scope.back = function () { $scope.myvar--; }; $scope.next = function () { $scope.myvar++; };

if next() (with ngclick) called 3 times, get:

//1

//2

//3

but if back() (with ngswipeleft) called returns

//-1

when i'm expecting

//2

what missing here?

update: including ngtouch details - seems problem.. ngtouch included.

when watch myvar value - exists twice - 1 ngswipeleft call, , 1 ngclick call

your snippet looks fine me. need provide more code, error might somewhere else. @ code below.

<!doctype html> <html ng-app="myapp"> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.12/angular.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular-touch.min.js"></script> <script> var app = angular.module('myapp',['ngtouch']); var controller = app.controller('mycontroller', ['$scope',function($scope){ $scope.myvar = 0; $scope.back = function () { $scope.myvar--; }; $scope.next = function () { $scope.myvar++; }; }]); </script> </head> <body ng-controller="mycontroller"> <div> <h1>myvar: {{myvar}}!</h1> <input type="button" value="back" ng-click="back()"/> <input type="button" value="next" ng-click="next()"/> </div> </body> </html>

javascript angularjs angularjs-scope angularjs-ng-touch

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -