angular-ng-if

Multiple Conditions in ngIf in Angular 6

给你一囗甜甜゛ 提交于 2019-12-23 19:33:34
问题 I want to hide one div and want to show another for that I have written below code My Code My problem is I have used multiple conditions in ngIf but not working properly. Once I click on "Show sub content1" want to hide main content and want to show "Sub Content 1" and vise versa for all buttons. What should I do for this. Please help. 回答1: Your were just near to your result and looking into your code looks like you are learning, Good Work!! you have to check just if any one of the content is

Angular ng-if change span text

蹲街弑〆低调 提交于 2019-12-22 04:17:15
问题 I have this JSON file that I am taking objects as products from. When displaying the sizes of the products I want to change a span from "sizes:" to "kids:" when the json object has "kids": "1". <div class="sizes-wrap"> <span class="size-label"><span>sizes:</span> <span class="sizes">{{ item.sizes }}</span> </div> this code prints Sizes: and the sizes from the json e.g. "128 cm,140 cm,152 cm,164 cm" I want when in the json object "kids" has a value of 1 to change the word "sizes" to "kids" in

AngularJs ng-if comparing dates

时光怂恿深爱的人放手 提交于 2019-12-22 02:01:16
问题 I am looking to compare two dates in ng-if this is what my jade file looks like. li.list-group-item(ng-if="app.Segments[0].StartDate.getTime() > date.getTime()") div.row div.col-xs-12 span i.fa.fa-plus-square This code will hopefully add an li to my ui if the startdate of the first segment is after today. $scope.date = new Date(); $scope.app = { Segments: [{ StartDate: 2014-11-15T04:00:00.000Z EndDate: 2014-11-20T04:00:00.000Z }, { StartDate: 2014-11-21T04:00:00.000Z EndDate: 2014-11-25T04:00

Model does not update within ng-if

旧街凉风 提交于 2019-12-22 01:53:44
问题 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"

How do I negate the parameter for AngularJS ng-if directive?

我只是一个虾纸丫 提交于 2019-12-18 18:56:35
问题 Quick Example: There is a routed parameter (/Home/:isLoggedIn) that equates to true or false. (/Demo/#/Home/false) and a controller property this.loggedIn = this.routeParams.loggedIn; I have a view (Home.html) that has two elements, each with an ng-if attribute. <div ng-if="home.loggedIn"> Logged In! </div> <div ng-if="!home.loggedIn"> Not Logged In... </div> If I navigate to /Demo/#/Home/true then the first element displays and the second does not. If I navigate to /Demo/#/Home/false then

Applying ng-class based on value

心不动则不痛 提交于 2019-12-18 04:04:30
问题 I have a simple ng-repeat that displays a list of scores and a value of either Positive or Negative. What i am trying to do is when the value is Negative, display a red background CSS class, and when Positive, display a green CSS class. However, for some reason, i am always seeing the red CSS class on my page. HTML: <tr ng-repeat="scores in Test" ng-class="{true: 'warning', false: 'ok'}[scores.Indicator == 'Negative']"> <td>Overall: {{ scores.Indicator }}</td> </tr> CSS: .warning { background

How to conditionally wrap a div around ng-content

吃可爱长大的小学妹 提交于 2019-12-17 10:33:50
问题 depending on the value of a (boolean) class variable I would like my ng-content to either be wrapped in a div or to not be wrapped in div (I.e. the div should not even be in the DOM) ... Whats the best way to go about this ? I have a Plunker that tries to do this, in what I assumed was the most obvious way, using ngIf .. but it's not working... It displays content only for one of the boolean values but not the other kindly assist Thank you! http://plnkr.co/edit/omqLK0mKUIzqkkR3lQh8 @Component

How to ng-if in angular 2

一笑奈何 提交于 2019-12-13 18:35:12
问题 <h3 style="color:#00bfff;margin:-14px 0 16px 0px" class="inline" *ng-if="data.for == 'next'"> {{data.bannerText}}<sup><small>{{data.super}}</small></sup> </h3> <span class="NotinStockGrey"> {{data.textOne}} </span> <span style="color:#00bfff"> {{data.textTWo}} </span> error: zone.js:420 Unhandled Promise rejection: Template parse errors: Can't bind to 'ng-if' since it isn't a known property of 'h3'. ("0Fb;margin:-16px 0 16px 0px"> 回答1: It's *ngIf="..." (not ng-if ) https://angular.io/docs/ts

ng-if not working, ng-show works

天大地大妈咪最大 提交于 2019-12-12 12:07:28
问题 I have an html where I must show AngularJS template only when I reach the bottom of the page (I've implemented infinite scrolling). The first page comes from the server. So I've to put an ng-if for that first page, because the user could have a bookmark with "address/page=5", and the html template for the first page from the server doesn't have to be in the page. Now I have the url "address", specific for the page from the server. ng-if doesn't work, the page is empty, but if I use ng-show it

Angular 2- using *ngIf with multiple conditions

前提是你 提交于 2019-12-12 08:20:20
问题 I'm unable to selectively display links on my nav-bar. Based on who logs in (user or admin), I want to change which link shows on my nav-bar. Below is the code for one such instance where the user/admin logs out. In navbar.component.html - <li *ngIf="authService.userLoggedIn()== true && authService.adminLoggedIn() == false" [routerLinkActive]="['active']" [routerLinkActiveOptions]="{exact:true}"> <a (click)="onUserLogoutClick()" href="#">Logout</a> </li> <li *ngIf="(authService.adminLoggedIn(