ng-if

Model does not update within ng-if

匿名 (未验证) 提交于 2019-12-03 08:35:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've got a strange behavior in an angular application and I don't know if that's a bug or a known limitation: 'use strict'; var ctrl = function ($scope) { $scope.foo = false; }; <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app ng-controller="ctrl"> foo: {{foo}} <div ng-if="foo" style="background-color: #f00;"> <p>foo</p> </div> <div ng-if="!foo"> <br/><button ng-click="foo = true;">Show foo</button> </div> <button ng-click="foo = true">Show foo</button> </div> http://jsfiddle.net/78R52

How to make use of ng-if , ng-else in angularJS

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to compare id.here if id equals 5 do this, else do that. How can I achieve this? <div class="case" data-ng-if="data.id === '5' "> <input type="checkbox" id="{{data.id}}" value="{{data.displayName}}" data-ng-model="customizationCntrl.check[data.id1]" data-ng-checked="{{data.status}}=='1'" onclick="return false;">{{data.displayName}} <br> </div> <div class="case" data-ng-else> <input type="checkbox" id="{{data.id}}" value="{{data.displayName}}" data-ng-model="customizationCntrl.check[data.id]" data-ng-checked="{{data.status}}=='1'">{

Using ng-if inside ng-repeat?

匿名 (未验证) 提交于 2019-12-03 02:12:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i am working on Angular app. I tried to use ng-if and switch inside ng-repeat but didn't succeed. I have data like: **[{"_id":"52fb84fac6b93c152d8b4569", "post_id":"52fb84fac6b93c152d8b4567", "user_id":"52df9ab5c6b93c8e2a8b4567", "type":"hoot",}, {"_id":"52fb798cc6b93c74298b4568", "post_id":"52fb798cc6b93c74298b4567", "user_id":"52df9ab5c6b93c8e2a8b4567", "type":"story",}, {"_id":"52fb7977c6b93c5c2c8b456b", "post_id":"52fb7977c6b93c5c2c8b456a", "user_id":"52df9ab5c6b93c8e2a8b4567", "type":"article",},** $scope.comments = data mentioned above