angular2-directives

Router directives in two places for same purpose

☆樱花仙子☆ 提交于 2019-12-20 05:19:46
问题 I am having a bit of trouble understanding the logic here root-component import { Component } from "angular2/core"; import { TopNavigationComponent } from "./shared/navigation.component"; import { ArcListComponent } from "./arc/arc-list.component"; import { ArcNewItemComponent } from "./arc/arc-new-item.component"; import { RouteConfig } from "angular2/router"; import { ROUTER_DIRECTIVES } from "angular2/router"; @Component({ selector: "ng2-app", template: ` <section class="jumbotron full

Equivalent to ng-repeat in Angular2 to get the keys of JSON object [duplicate]

做~自己de王妃 提交于 2019-12-20 02:26:20
问题 This question already has answers here : Select based on enum in Angular2 (9 answers) Closed 3 years ago . I'm looking for a way to browse a JSON object into an HTML page with Angular2. In order to get each keys and each values. In AngularJS, it's possible with the directive ng-repeat : <div ng-repeat="(key, data) in dataSets">{{key}}</div> But in Angular2, i don't find a good way to do like this. This is my object : Object {name: "Rue Saint-Nestor", oneway: "yes", highway: "residential",

Delay navigating to next page

痴心易碎 提交于 2019-12-20 02:13:57
问题 My angular site works great, but when you click into a project it loads the page, right away and sometimes there is a flash while the images are pulled from the API , id like a 1 second delay, or page transition effect. but i'm not sure how to implement this in Angular 2. Interested to hear what others are doing ? Thanks in advance 回答1: You can implement CanDeactivate interface, something like this: routerCanDeactivate(currTree?: RouteTree, futureTree?: RouteTree): Promise <boolean> { return

Why (ngModel) is not working?

*爱你&永不变心* 提交于 2019-12-20 01:09:44
问题 I have running the sample application to learn angular 2. In my sample application [(ngModel)] is not working. But when i removes the square brackets (ngModel) the screen is loading but two way binding is not working. should i do anything for making [(ngModel)] work. 回答1: Probably your code is missing this import line in your module: import { FormsModule } from '@angular/forms'; You also have to add FormsModule to module imports array: @NgModule({ imports: [FormsModule, /*...*/ ], //... }) 来源

How can I specify query parameters by routerLink directive

这一生的挚爱 提交于 2019-12-19 17:45:32
问题 I am experimenting the new router (version 3.0.0-alpha.7) and would like to know how to specify query parameters by routerLink directive? The Router.navigate() method below generates a URL like http://localhost:3000/component-a?x=1 this.router.navigate(['/component-a'], {queryParams: {x: 1}}); However, I can't figure out how to do the same thing with the routerLink directive. Template like below returns parser error... <a [routerLink]="['/component-a'], {queryParams: {x: 1}}">Component A</a>

How to utilize jqGrid in Angular 2+?

孤人 提交于 2019-12-18 17:29:39
问题 In my current project we have been using jqGrid in almost every page. We use the grid's full rich featureset including complex grid inline row editing, with drop down, check box and other controls, sorting, column filtering and more. Now we wish to convert our project into angular 2, but our main problem is replacing jqGrid's rich featureset. Before starting I need to do some POC if all the functionalities can be done in angular 2 based grid. How can jqGrid be used in Angular 2+? 回答1: You don

Angular 2 Directive implementing ControlValueAccessor doesn't update 'touched' property on change

有些话、适合烂在心里 提交于 2019-12-18 15:17:27
问题 I'm trying to create my own Angular 2 Directive for Jquery UI Datepicker. I've seen some different approaches on the internet and in SO as well, but no one achieves the goal that I want to. So this is the code that I have so far: import {Directive, ElementRef, Input, forwardRef} from '@angular/core'; import {ControlValueAccessor, NG_VALUE_ACCESSOR} from "@angular/forms"; declare var $:any; @Directive({ selector: '[date-picker]', providers: [{ provide: NG_VALUE_ACCESSOR,useExisting: forwardRef

Angular2 How to get reference of HTML elements generated dynamically

删除回忆录丶 提交于 2019-12-18 12:53:10
问题 I have this inputs generated dynamically: <div *ngFor="let cell of column; let i = index;"> <!-- Material design input--> <md-input id="my-input-{{i}}"> </md-input> </div> Please notice id=my-input-{{i}} I would like to get a reference to the DOM element based on this dynamic id. This input can be 3, 6 or more inputs so I need to access the id dynamically and get a hold to it. 回答1: The only response is let elem:Element = document.getElementById("myProgrammaticallyChosenIndex") No other

Angular2 How to get reference of HTML elements generated dynamically

跟風遠走 提交于 2019-12-18 12:53:01
问题 I have this inputs generated dynamically: <div *ngFor="let cell of column; let i = index;"> <!-- Material design input--> <md-input id="my-input-{{i}}"> </md-input> </div> Please notice id=my-input-{{i}} I would like to get a reference to the DOM element based on this dynamic id. This input can be 3, 6 or more inputs so I need to access the id dynamically and get a hold to it. 回答1: The only response is let elem:Element = document.getElementById("myProgrammaticallyChosenIndex") No other

Angular2: Cloning component / HTML element and it's functionality

旧时模样 提交于 2019-12-18 12:11:20
问题 So, the question is fairly simple... I have a table and some angular logic on it (calculating styles, etc)... specifically I have this on THs [class.hidden] = "column.group !== 'key-data' && currentTableView !== column.group" For my table sticky headers functionality I need to clone the table and position it fixed.. using a directive, that does something like this (simplified) let newTable = element.cloneNode(true); body.appendChild(newTable); obviously the angular logic is not applied to the