Questions tagged [angular-ng-if]

'ngIf' is an Angular core directive that toggles the presence of the targeted element in the DOM. Do not use this tag for the 'ng-if' directive in the older AngularJS version.

ngIf is an Angular directive that alters the targeted element.

From the documentation:

Conditionally includes a template based on the value of an expression.

1223 questions
3
votes
1 answer

angular 2 ngIf Unexpected token #

Hi everyone i'm study angular2 now im workind with *ngIf and i have this code

List of courses

3
votes
2 answers

How to show 1 element in an array using ngFor Angular2

On my website if I have more than one element in my array. My template looks like this. I want to have a button to go to the next element of this array and only display one set of data and use the button to control which element of the array the…
Edward Muldrew
  • 77
  • 1
  • 13
3
votes
3 answers

Angular2 ngIf creates empty element when false

I have a problem with Anguar2 and ngIf: I have a code that creates a table from an array(with a DIY coded offset of 6):
ThatsEli
  • 39
  • 1
  • 7
3
votes
1 answer

Angular ng-if counting divs

I have some filters using ng-show and I need show a div when all others div it's hidden. I create a function to count divs, it's work but when all divs is hidden the div only show in next interation, for example. I have 3 divs, Plan 1, Plan 2 and…
3
votes
1 answer

Show data from JSON Using Angular 2 - Observable and async

I have a simple Angular 2 service that is calling a local JSON file. I can get the object to console.log in the .map function in the general.service.ts. However, due to the nature of the async call I cannot seem to print out a single key or value…
Sam Kelham
  • 1,357
  • 4
  • 15
  • 28
3
votes
1 answer

Angular 2 ngIf clears value

I want to hide a tablerow if the string value of the url property of my project is empty. So this is my code:
3
votes
3 answers

Angular2 - ngIf in a ngFor

I want to check if the actual element has a value or not. For Example I want to check if the chocolate is black or white. Depending on this, I want to display the right text.
ALSTRA
  • 661
  • 3
  • 12
  • 30
3
votes
3 answers

How to use 'ng-if' in Angular 2

Consider:

{{data.bannerText}}{{data.super}}

{{data.textOne}}
Gulshan Trivedi
  • 69
  • 1
  • 1
  • 2
3
votes
2 answers

How to use ng-if with ng-disabled

Below is my Code. var myfriend = angular.module('myfriend',[]); myfriend.controller('myfriendController', function($scope) { $scope.record = [ { "id" : "01", "firstname" : "Mohan ", "middlename" :…
3
votes
4 answers

angularjs - ng-if Multiple Conditions

So this has been asked before but my question isnt as simple as ng-if="country == 'ireland' || country='United Kingdom'" I need to do something like: ng-if="(country='ireland' || country='united kingdom') || (name='John' || name='Joe')" What im…
Shiny
  • 105
  • 2
  • 2
  • 7
3
votes
2 answers

Alternative name for *ngIf directive

A long time ago Angular 2's docs mentioned an alternate name for *ngIf, that didn't use an asterisk. I believe it was something similar to -ng-if where was some short prefix. I cannot find any reference to this in the latest…
kantianethics
  • 671
  • 5
  • 21
3
votes
2 answers

AngularJS - ng-if if there is a specific value in array

I would like to trigger ngIf when there is a specific value in an array inside the scope. So I have this on my scope: var orders = [{ "order_no": 1, "color": ["blue", "pink", "red"] }, { "order_no": 2, "color": ["yellow", "blue",…
Joe82
  • 1,357
  • 2
  • 24
  • 40
3
votes
3 answers

How to DRY up list in angular

This is my first time posting a question on stackoverflow so sorry if its not in the correct format. I keep running into the same problem in angular and i'm sure there is a very simple way to solve it but for some reason i can't figure it out. I…
3
votes
2 answers

How to retrigger ng-if / ng-show animation when using $http cache

Within a factory service, I have to use $http.get(url, { cache: true }) In my view, i am using ng-if or ng-show to trigger a CSS transition. The problem : It is working great for the first request, but obviously for the next request of the same…
jDelforge
  • 129
  • 4
  • 15
3
votes
3 answers

AngularJs show first and last from filtered list

Have some problem show only first and last repeated element after filtering empty string from array. My code: var myApp = angular.module('myApp', []); myApp.controller("myCtrl", function ($scope, $window) { $scope.items = [ {…
KingStakh
  • 303
  • 3
  • 13
Raum Ticket