I really can not understand what the problem is in this code:
App.directive ('counter', function () {return: 'a', scope: {}, template: ' Span class = "glyphicon glyphicon-chevron-up" data-ng-click = "increment ()"> Controller: function ($ scope) {$ Scope.qnt = 1; $ scope.increment = Summary H () {$ scope.qnt ++;}; $ scope.decrement = function () {console.log ($ scope.qnt> 1); if ($ scope.qn) t> 1) { $ Scope.qnt--;} Console.log ($ scope.qnt);};}, link: function (scope, element, etter) {}};}); Salary increment works, does not work in decreasing. What is wrong?
You do not have any closed tags for increments The period was due to this, when the decreasing code was being executed, the increment code was also occurring, it was terminating the deficit.
Template: '& lt; Div class = "item-counter" & gt; & Lt; Input type = "text" data-ng-model = "qnt" & gt; & Lt; Span class = "glyphicon glyphicon-chevron-up" data-ng-click = "increment (")> & Lt; / Span & gt; & Lt; Span Class = "glyphicon glyphicon-chevron-down" data-ng-click = "decrease ()" & gt; & Lt; / Span & gt; & Lt; Button Type = "Button" class = "BTN BTN-Success" & gt; Aggiungi & lt; / Button & gt; & Lt; / Div & gt; ',
updated plunk
Comments
Post a Comment