angular2-directives

Router directives in two places for same purpose

一个人想着一个人 提交于 2019-12-02 06:14:19
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-height"> <top-navigation></top-navigation> <div class="container"> <router-outlet></router-outlet> </div>

How can I reuse HTML in multiple places without an additional component

半世苍凉 提交于 2019-12-02 01:59:55
问题 I'm currently trying to i18n the menu to display the columns to show. I realized I can use the following to customize its text. <clr-dg-column-toggle> <clr-dg-column-toggle-title>{{‘clr.dg.column.toggle.title’ | translate}} </clr-dg-column-toggle-title> <clr-dg-column-toggle-button clrType = “selectAll”>{{‘clr.dg.column.toggle.selectAll’ | translate}} </clr-dg-column-toggle-button> </clr-dg-column-toggle> However, we have over 50 grids and I would like to avoid copy pasting this into all of

ViewChild - Not working in Angular 2 RC 1 JavaScript

浪子不回头ぞ 提交于 2019-12-01 22:47:46
问题 ViewChild is not woring in Angular 2 RC 1 JavaScript. I have used <router-outlet> . Can anyone help me to solve this issue? Thanks in advance. Following is my sample code app.AppComponent = ng.core. Component({ selector: "app", template: '<div>' + ' <router-outlet></router-outlet>' + ' <div (click)="submit()">Submit</div>' + '</div>', queries: { 'viewChild1Component': new ng.core.ViewChild(app.Child1Component) }, directives: [ng.router.ROUTER_DIRECTIVES] }) .Class({ submit: function() {

Why (ngModel) is not working?

旧街凉风 提交于 2019-12-01 19:51:15
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. 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, /*...*/ ], //... }) 来源: https://stackoverflow.com/questions/43994919/why-ngmodel-is-not-working

Angular2: what expressions can we interpolate in template

时间秒杀一切 提交于 2019-12-01 19:41:47
I read that we can interpolate Javascript expressions. What is the list of valid Javascript expressions that we can interpolate? So far for interpolation I have a displayed property, eg. object.property , short expressions like {{1+1}} what else Javascript expressions can we interpolate? Expressions in Angular2 are very similar to expressions in Angular in terms of the scope of what they allow. JavaScript expressions that promote side effects are prohibited including Assignment (= +=, -=) Using the new keyword Chaining expressions using a semicolon or comma Increment (++) and decrement

Dynamically mount angular 2 directive [duplicate]

梦想与她 提交于 2019-12-01 17:58:50
问题 This question already has an answer here : How to instantiate and apply directives programmatically? (1 answer) Closed 2 years ago . Context I have a simple directive that add some attributes to a given HTML element based on received attributes. <button class="btn btn-blue x-large" [myDirective]="{ some_json_data: true }"> Unfold </button> The myDirective directive just does some logic in the ngOnInit hook and decorates the ElementRef native element (in this case the button) adding attributes

Controlling order of directive evaluation in Angular 2

你离开我真会死。 提交于 2019-12-01 17:49:59
I want to create an attribute directive in Angular 2. It needs to have a click handler on its host. The click handler needs to be added before the other directives on the element are evaluated because it controls access to certain functionality. In Angular 1, you could do this with the priority option when creating a directive. Is there some sort of equivalent in Angular 2? Thanks, Chase Mark Kennedy priority in Angular 2 is not supported, and there isn't any plan to add it. Component directives may not use the following attributes: priority and terminal . While Angular 1 components may use

Dynamically mount angular 2 directive [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 17:48:27
This question already has an answer here: How to instantiate and apply directives programmatically? 1 answer Context I have a simple directive that add some attributes to a given HTML element based on received attributes. <button class="btn btn-blue x-large" [myDirective]="{ some_json_data: true }"> Unfold </button> The myDirective directive just does some logic in the ngOnInit hook and decorates the ElementRef native element (in this case the button) adding attributes, nothing complicated. ngOnInit(): void { const el: Element = this.element.nativeElement; this.decorate(el, this.myDirective);

Angular 2 component without selector tag in DOM

陌路散爱 提交于 2019-12-01 17:43:32
问题 I want this: <div *ngIf="...">div 1...</div> <div *ngIf="...">div 2...</div> <div *ngIf="...">div 3...</div> But I don't wanna repeat the *ngIf , so I created my component <my-component> , with this template: <div>div 1...</div> <div>div 2...</div> <div>div 3...</div> And I put *ngIf in my component tag: <my-component *ngIf="..."> The problem is that Angular 2 is putting the <my-component> tag in the DOM, and I don't want it. For anyone who knows ASP.NET WebForms, I want a component in

How can I specify query parameters by routerLink directive

余生长醉 提交于 2019-12-01 17:12:14
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> And the closest thing I can get is http://localhost:3000/component-a;x=1 , which uses the syntax for