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
2
votes
1 answer

Angularjs: ng-repeat + ng-switch-when != expected

The following code doesn't seem to work correctly:
{{solution.content}}
The output of {{solution.title}} is…
Martin Christov
  • 155
  • 2
  • 9
2
votes
1 answer

In Angular.js, is it possible to replace an ng-switch directive element with its contents?

I'm using a switch to conditionally include different content. I want the inner content (e.g. welcome directive) to replace the parent ng-switch element. I know that you can do this with custom directives using the replace=true configuration…
user2455709
  • 21
  • 1
  • 3
2
votes
1 answer

Ng-switch embedded in custom directive not getting evaluated when value changes

I created a custom directive that's basically a reusable form. Part of the form is an error message display that uses ng-switch:
Error encountered
wciu
  • 1,183
  • 2
  • 9
  • 24
2
votes
1 answer

AngularJS switch expression evaluates but does not trigger correct result

I am trying to use a switch to control some image url parameters. My image.marketplace node is a image.url.indexOf('?') and evaluates to either -1 or a positive integer if a question mark is present in the url. I can get my expression (ng-switch…
2
votes
1 answer

Angular directive's link function called with empty element parameter

I have a scenario where a directive's link function is called with an empty element parameter leading to errors. A code example describes the scenario best: index.html:
Scripts: var…
Paul Pepper
  • 707
  • 1
  • 8
  • 17
1
vote
1 answer

How to have different components in the ngbNav tabs?

I am using Angular and ngbNav to create tabs. The problem is that I have tab names from the API and to show them I need ngFor, but also for the content of the tab I should show different components. To implement that I have used ngSwitch.
1
vote
2 answers

Angular:Trying to do ngSwitch with Conditions

I'm interested in doing ngswitch in case and The number is greater than 5 So give 50 px to its font size The number is less than 2 so give it 15 px.... I could not find a suitable syntax so there is no code here
1
vote
1 answer

How to use ngswitch with enum in template?

I'm trying to change template with enum values. TS: enum NumType { first, second, third } @Component({ selector: 'app-test', template: `
first
BondBill
  • 11
  • 3
1
vote
1 answer

Angular select visible element based on some value

I get a list of items from a service as an (observable) array. The elements in the have a type: string; field, which I intend to use as an indicator for selecting different components to display. When I don't have a widget for a type yet, I want to…
Wr4thon
  • 554
  • 1
  • 5
  • 11
1
vote
1 answer

How to detect ngSwitch changes in Angular page

Currently I am integrating Stripe into Angular. The implementation works fine until I started moving the Stripe Elements into an ngSwitchCase and ng-container That's when I started getting this error: ERROR IntegrationError: The selector you…
chris
  • 2,490
  • 4
  • 32
  • 56
1
vote
0 answers

jQuery not working with select tag and ngSwitch, why?

I'm building an interactive floorplan directory with svgs using AngularJS and a little bit of jQuery. The idea is that when you click on a name and/or department the slider will scroll to the floor its on and the room its located in using an href…
Nick
  • 21
  • 5
1
vote
2 answers

How to use ngSwitch with *ngFor in Angular 6

I have a Map as follows with dynamic keys and values public featureData = new Map(); Key value pairs will be as follows (other dynamic values may present) [ {"name" : "Bangalore"}, {"type" : "city"}, {"lat" : "12.9716"}, …
Basil
  • 1,664
  • 13
  • 25
1
vote
1 answer

correct ngSwitchCase doesn't make paragraph appear

I have a button that assigns one of two strings from an array to a variable. then, using [ngSwitch] I want to display only one paragraph. None of the paragraphs seem to appear, I'm only getting the random alert on every button click. Oh, and the…
1
vote
1 answer

ng-switch not passing argument

I'm using ng-switch to switch between two functionalities on my webapp, downloading and uploading (controlled by two buttons). When the user wants to download, I use a textbox and submit button to pass the search query to an $http POST request in my…
Quinn Tai
  • 55
  • 1
  • 7