ng-switch

Loading map to ngSwitch child scope using ElementRef in Ionic

对着背影说爱祢 提交于 2019-12-23 17:09:41
问题 I'm trying to access a ngSwitchCase view using @ViewChild and ElementRef to load a google map in my Ionic 3 app. I understand the ngSwitch creates its own scope but is it not accessible in anyway so I can load the map from google to the #map id="map" div in the mapView ngSwitchCase ? page.ts //the import import { ElementRef, ViewChild } from '@angular/core'; @Component({ selector: 'page-views', templateUrl: 'views.html' }) export class ViewsPage { //the attribute in the export class

Angular js : Dynamic expression not working for ng-switch-when

血红的双手。 提交于 2019-12-20 07:39:58
问题 I have a div based on switch but the switch has a boolean variable but the value will be evaluated based on the row.id. Can some one tell me what I am doing wrong here ? <div ng-switch="hasUrl"> <a ng-switch-when="row.id.indexOf(':') < 0 === true" href="{{url + row.id}}"> <!-- hasUrl = true --> {{getName(row)}} </a> <a ng-switch-default href="......."> {{getName(row)}} </a> </div> 回答1: You don't need the === , remove it. <div ng-switch="hasUrl"> <a ng-switch-when="row.id.indexOf(':') < 0"

Problems when using ng-options and ng-switch together

Deadly 提交于 2019-12-12 01:22:16
问题 I have an issue when I am trying to use ng-options and ng-switch together in AngularJS to dynamically change what content is put on the page for a widget builder I am working on. I have two issues I am experiencing: 1. I can't seem to set ng-option to default to the value being set by the model from the json it displays. 2. When I change the ng-option field the switch below breaks and no longer showes the correct code. Here is the code: <div ng-app=""> <div data-ng-controller=

ng-switch and ng-repeat on the same element interfearing

余生长醉 提交于 2019-12-08 15:36:29
问题 I encountered behaviour in Angular I did not expect and the purpose of this post is to find out whether this is a bug or intended and possibly an explanation why it is intended. First see this Plunkr: http://plnkr.co/edit/CB7k9r?p=preview . In the example I created an array called array with three object entries. Further I created a ng-switch based on the content of an input field (called toggle). When the value of toggle is 1 it should print all names of the objects in the array prefixed

ng-switch in Angular2

一笑奈何 提交于 2019-12-08 15:27:06
问题 I am playing around with angular 2 (currently with version alpha 26). ng-for and ng-if for example are working fine. I do however have problems with ng-switch . I just can't get it to work, i.e. nothing is printed. It seems as if the whole template is ignored. This is the code from my component, which can also be found on github: import {Item} from "js/types/item"; import {Component, View, NgFor, NgIf, NgSwitch} from "angular2/angular2"; @Component({ selector: "item-details", properties: [

ng-repeat and ng-switch doesn't work on same element

佐手、 提交于 2019-12-07 19:23:03
问题 JS $scope.mode = "test" $scope.array = ['test1', 'test2', 'test3'] HTML <div ng-switch on="mode"> <div ng-repeat="item in array" ng-switch-when="test"> Test {{item}} </div> </div> When I do this the above, the output I get is Test Test Test It can't seem to access item. If I remove the ng-switch-when then it works fine. 回答1: It is because ng-switch creates a child scope and same applies for ng-repeat. ng-repeat runs at priority 1000 and ng-switch at 800 . So the child scope created by ng

Angular2 - Template reference inside NgSwitch

做~自己de王妃 提交于 2019-12-07 16:06:59
问题 I have a NgSwitch template. In the NgSwitch I want to get a template reference to the initialized template. Something like this: <div class="container" [ngSwitch]="model.type"> <first-component #ref *ngSwitchCase="0"></first-component> <second-component #ref *ngSwitchCase="1"></second-component> <third-component #ref *ngSwitchCase="2"></third-component> </div> When clicking on a button in the component I want to call to the initialized component (first/second/third) to a method (which defined

How to prevent controller reloading when using ng-switch

女生的网名这么多〃 提交于 2019-12-06 05:44:50
问题 In this example, using ng-switch, I'm able to switch between different views. Each view is assigned a controller. I've put a quick sample online here : http://jsfiddle.net/FBHjZ/1/ It looks like the controller is reinstanciated everytime I switch views : If you enter a val in the input field, go to home and switch back to settings, the value is lost. How can I prevent this? Basically, what I want is to keep state from previous views when I switch between views. 回答1: There is no way of

Angular2 - Template reference inside NgSwitch

时间秒杀一切 提交于 2019-12-05 19:00:32
I have a NgSwitch template. In the NgSwitch I want to get a template reference to the initialized template. Something like this: <div class="container" [ngSwitch]="model.type"> <first-component #ref *ngSwitchCase="0"></first-component> <second-component #ref *ngSwitchCase="1"></second-component> <third-component #ref *ngSwitchCase="2"></third-component> </div> When clicking on a button in the component I want to call to the initialized component (first/second/third) to a method (which defined on an interface that all these 3 component implement). The problem is the ViewChild is undefined. If I

angularjs: multiple values in a ng-switch-when

孤人 提交于 2019-12-04 14:55:12
问题 I have the following ngSwitch: <p ng-switch="status"> <span ng-switch-when="wrong|incorrect"> Wrong </span> <span ng-switch-default> Correct </span> </p> As you can see, I have the text Wrong for two options wrong and correct . I have tried (as you can see) to use the pipe | , but that doesn't work. Any suggestions ? 回答1: For angular >=v1.5.10, You can do it by adding ng-switch-when-separator="|" to ng-when node. see example in documentation. <span ng-switch-when="wrong|incorrect" ng-switch