C
C
cvbcvb cvbcvbcvbcvb2016-03-12 23:38:26
JavaScript
cvbcvb cvbcvbcvbcvb, 2016-03-12 23:38:26

Why doesn't ng-if work?

Tell me
why ng-if doesn't work in button toggle?
ng-show works, but no if.
Below, where we switch edit and close

<section class="blockLayout">
    <div class="noteBlock {{n.color}}" ng-repeat="n in notes | filter:searchNote">
        <h5>
        	<span ng-if="s">{{n.title}}</span>
        	<input type="text" ng-model="n.title" ng-if="!s">
        </h5>
        <p>
            <span ng-if="s">{{n.text}}</span>
            <input type="text" ng-model="n.text" ng-if="!s">
        </p>
        <div class="colorEditor" ng-if="!s">
          <input class="with-gap" name="colors" type="radio" id="yellow{{$index}}" value="yellow" ng-model="n.color">
          <label for="yellow{{$index}}">Yellow</label>
          <input class="with-gap" name="colors" type="radio" id="blue{{$index}}" value="blue" ng-model="n.color">
          <label for="blue{{$index}}">blue</label>
          <input class="with-gap" name="colors" type="radio" id="cyan{{$index}}" value="cyan" ng-model="n.color">
          <label for="cyan{{$index}}">cyan</label>
        </div>
        <a class="btn-flat" ng-show="s" ng-click="s = false">Edit</a>
        <a class="btn-flat" ng-show="!s" ng-click="s = true">Close</a>
        <button class="btn red accent-4" ng-click="deleteNote($index)">Delete</button>
    </div>
</section>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-03-19
@koilil

Your example works for me

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question