AngularJS ng-show directive not working on scope function like it should -


What's wrong with this simple ng-show directive? It should be simple because I have hidden buttons through the ng-show and when a third button is clicked, these two buttons will be displayed so long as they are not clicked, they hide. < P> javascript

  $ scope.addQuestion = function () {$ ('button # addquestion'). Click (function () ($ scope.addQuestion = true; console.log ("clicked");})}   

HTML

  & lt ; Div class = "program-edit-btns well" & gt; & Lt ;! - These two buttons are hidden until the third button is clicked - & gt; & Lt; Div class = "btn-group pull-left" ng-show = "plus question ()" & gt; & Lt; Button type = "button" class = "BTN-remove BTN" & gt; & Lt; I class = "fa fa-plus" & gt; & Lt; / I & gt; Add & lt; / Button & gt; & Lt; Button type = "button" class = "BTN-remove BTN" & gt; & Lt; I class = "fa-file-o" & gt; & Lt; / I & gt; Copy & lt; / Button & gt; & Lt; / Div & gt; & Lt ;! - this button ng-show - & gt; & Lt; Button id = "addQuestion" type = "button" class = "BTN BTN-Remove pull-left" & gt; & Lt; I class = "fa-plus" & gt; & Lt; / I & gt; Question & lt; / Button & gt; & Lt; / Div & gt;    

You found and got the match. You need it: -

More jquery click event handlers, just add a handler function, set the variable to the scope: -

  $ scope.addQuestion = function () {$ scope.showQuestion = true; }   

and ng-show = "show question" on the section and ng-click = "plus question ()" triggers .

  & lt; Div class = "program-edit-btns well" & gt; & Lt ;! - These two buttons are hidden until the third button is clicked - & gt; & Lt; Div class = "btn-group pull-left" ng-show = "show question" & gt; & Lt; Button type = "button" class = "BTN-remove BTN" & gt; & Lt; I class = "fa fa-plus" & gt; & Lt; / I & gt; Add & lt; / Button & gt; & Lt; Button type = "button" class = "BTN-remove BTN" & gt; & Lt; I class = "fa-file-o" & gt; & Lt; / I & gt; Copy & lt; / Button & gt; & Lt; / Div & gt; & Lt ;! - this button ng-show - & gt; & Lt; Button id = "add questions" ng-click = "plus question ()" type = "button" square = "btn-btn-remove pull-left" & gt; & Lt; I class = "fa-plus" & gt; & Lt; / I & gt; Question & lt; / Button & gt; & Lt; / Div & gt;    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -