Questions tagged [ng-switch]

The ngSwitch directive is used to conditionally swap DOM structure on your template based on a scope expression. Elements within ngSwitch but without ngSwitchWhen or ngSwitchDefault directives will be preserved at the location as specified in the template.

Usage

<ANY ng-switch="expression">
  <ANY ng-switch-when="matchValue1">...</ANY>
  <ANY ng-switch-when="matchValue2">...</ANY>
  <ANY ng-switch-default>...</ANY>
</ANY>
197 questions
1
vote
1 answer

ng-switch does not work with angular-ui typeahead

I am using angular-ui typeahead directive and ng-switch. The objective is when the typeahead input box has been keyed in, a row that starts with "Person info" will appear. Otherwise, it will not appear. The problem now is that this row always…
guagay_wk
  • 26,337
  • 54
  • 186
  • 295
1
vote
2 answers

Angular JS: ng-switch on boolean not working

I am trying to conditionally display a directive based on a boolean value stored in the parent scope. I can't figure out why the below does not work. By, "not work" I mean neither directives are displayed.
1
vote
1 answer

AngularJS Directive to render an array of n elements as tables of m rows each

Problem: Given an array of 'n' items I want them rendered in separate tables of m rows each. For example, if I have an array of n=30 items and m=6 then I need 5 tables of 6 items each appearing horizontally stacked together. Attempted Solution: I…
Sid
  • 7,511
  • 2
  • 28
  • 41
1
vote
1 answer

AngularJS Bootstrap UI TypeAhead on-select does not update ng-switch

I'm somewhat new to angular and am wondering why when using Angular Bootstrap UI's Typeahead, I cannot update ng-switch. Essentially, what I'm trying to do is update the view based on the selection from a list. %input{"ng-model" =>…
eadon
  • 13
  • 1
  • 4
1
vote
2 answers

AngularJS Animations ng-switch ng-repeat

I am trying to do what looks like a simple process: to display a list of items received from an HTTP request with animation. First of all, here is my way of doing it ( I am open to any suggestions to do it in a better angular way ): I define a…
1
vote
1 answer

Angular ng-switch Common code for multiple cases?

Can I have replicate this switch statement behavior for Angular ng-switch directive anyway? switch(variable){ case 'sample1': case 'sample2': //So common functionality for both 'sample1' and 'sample2' could be written here break; case…
Peter Parker
  • 358
  • 1
  • 4
  • 12
1
vote
1 answer

AngularJS Directives: Using ng-switch breaks transclusion

I have created a directive for displaying large amounts of data in a tree structure. When an element is collapsed, its content is hidden using the ng-show command. Here is a heavily simplified version on plunker. The directive is called…
Pete Gardner
  • 505
  • 1
  • 5
  • 16
1
vote
1 answer

ng-switch to change user interface of a directive

I've created a directive for showing a person details: angular.module('person.directives', []). directive("person", function() { return { restrict: "E", templateUrl: "person/views/person.html", replace: true, scope: { …
Sam
  • 13,934
  • 26
  • 108
  • 194
0
votes
0 answers

Using multiple ngSwitchCase via (boolean) logic on the component

At this moment I have the following code on the template (source logic):
Calvin
  • 61
  • 10
0
votes
0 answers

ng Switch Angular data matching when changing

add-university.component.html
0
votes
0 answers

Angular ngIf statement

This is a component that reuse in a form for registering item. here i have some types. like for a phone number there are work, home, mobile types. value for 'data' are taken from service file. type.component.html
0
votes
0 answers

angular image change on condition

currently I am making a mini game with angular, and I already have most functionalities working. I am currently struggling to implement to change picture every time either (not have decided yet): change from A->F whenever I have collision with an…
0
votes
0 answers

Limit component from being initialized more than once with promise based ngSwitchCases on template and component

I am developing an application using ForgeRock's SDK. ForgeRock SDK returns promise based callbacks within each step of the user's authentication journey. I am using *ngSwitchCases on the template and on the main component to add the necessary…
0
votes
1 answer

Angular , mat-table, html element toggle

How do I toggle between two html elements based on what value I have in Table column ? As Column value is loaded into dataSource variable and I am rendering it. So is there any way I can use column value to render a specific html .
0
votes
1 answer

Use ngSwitch to switch between components in Angular 11 a href?

I have to child components and I want to be able to switch between two sub components but it not working. I have no idea how to implement it here. This is my example code HTML

Choose View

A
Fash
  • 309
  • 1
  • 13