angular2-directives

How do I extend RouterOutlet when using the new router in RC.1

折月煮酒 提交于 2019-12-30 06:33:31
问题 I can't seem to extend RouterOutlet when using the new router in RC.1 Example: import { Directive } from '@angular/core'; import { Router, ROUTER_DIRECTIVES, RouterOutlet } from '@angular/router'; @Directive({ selector: 'router-outlet' }) export class RouterOutletDirective extends RouterOutlet { } The error: @angular/router/index"' has no exported member 'RouterOutlet'. Am i doing something wrong or is this broke with the new router in RC.1? Updated: import { Directive, Attribute,

Angular 2 async pipe not rendering/updating Observable data automatically

孤街浪徒 提交于 2019-12-29 09:13:29
问题 I am facing an issue with the Angular2 router and an async pipe. I am trying to render an RxJs Observable and the data does not render automatically. One has to click on the link for the route for the data to render. Here is the root app: import {bootstrap} from 'angular2/platform/browser'; import {HTTP_PROVIDERS} from 'angular2/http'; import {ROUTER_PROVIDERS} from 'angular2/router'; import {AppComponent} from './app.component.ts'; bootstrap(AppComponent, [HTTP_PROVIDERS, ROUTER_PROVIDERS]);

Angular 2 async pipe not rendering/updating Observable data automatically

核能气质少年 提交于 2019-12-29 09:13:12
问题 I am facing an issue with the Angular2 router and an async pipe. I am trying to render an RxJs Observable and the data does not render automatically. One has to click on the link for the route for the data to render. Here is the root app: import {bootstrap} from 'angular2/platform/browser'; import {HTTP_PROVIDERS} from 'angular2/http'; import {ROUTER_PROVIDERS} from 'angular2/router'; import {AppComponent} from './app.component.ts'; bootstrap(AppComponent, [HTTP_PROVIDERS, ROUTER_PROVIDERS]);

How to get width of (DOM) Element in Angular2

和自甴很熟 提交于 2019-12-29 04:29:10
问题 there a some similiar threads but I couldn't find a suitable answer for my needs. So that direct DOM access should be strictly avoided in angular2 I'm just wondering whats best practice for this. What I wan't to achieve is a resize of a element based on the current width. workitemresize.component.ts import { Directive, ElementRef, HostListener, Renderer, Input } from '@angular/core'; @Directive({ selector: '[workItemResize]' }) export class WorkItemResizeDirective implements ngAfterViewInit {

How to import jQuery to Angular2 TypeScript projects?

旧巷老猫 提交于 2019-12-28 02:55:06
问题 I want to wrap some jQuery code in an Angular2 directive. I installed jQuery library for Typings into my project with the following command: typings install dt~jquery --save --global So now i have jquery folder under typings/global folder in my project directory. In addition the following new line has been added to my typings.json file: { "globalDependencies": { "core-js": "registry:dt/core-js#0.0.0+20160602141332", "jasmine": "registry:dt/jasmine#2.2.0+20160621224255", "node": "registry:dt

Toggle button based on json response in angular 2

风格不统一 提交于 2019-12-25 18:14:35
问题 I am trying to toggle button based on backend response.If the response is Yes, toggle button should be ON, if the response is No, toggle button should be off. Below is my html code <div class="btn-group btn-toggle"> <button class="btn btn-sm btn-default">ON</button> <button class="btn btn-sm btn-primary ">OFF</button> </div> Below is my component code, where i calling a get service which returns response either Yes or No.I am calling the service in ngOnit() because i want to check whether the

Why am I able to access private member of the class?

允我心安 提交于 2019-12-25 06:23:53
问题 My code is as follow @Component({ selector: 'my-app', template: ` <ul> <li *ngFor = 'let hero1 of heros2'> {{hero1.name}} </li> </ul> `}) export class AppComponent { heros2 : any = [ new heross('lee', 'lee'), new heross('lee1', 'lee1'), ];} class heross{ private name : string; constructor(name : string, details : string){ this.name = name; }} bootstrap(AppComponent); why am I able to access name in the view and displaying name, provided that I have given it private keyword 回答1: If you'll try:

How to manage the roles and permission in angular 2

非 Y 不嫁゛ 提交于 2019-12-24 19:23:15
问题 Hi I have stored the below data "permission": { "1000": "CREATE_DISBMT_WORKFLOW", "1001": "EDIT_DISBMT_WORKFLOW", "1002": "EDIT_UPLOAD_PHOTO_DISBMT_WORKFLOW", "1003": "EDIT_UPLOAD_CONFIRMED_DISBMT_WORKFLOW", "1004": "EDIT_VERIFIED_DISBMT_WORKFLOW", "1005": "VIEW_DISBMT_WORKFLOW", "1006": "DELETE_DISBMT_WORKFLOW" } in local storage now I want to create a function on which I will pass CREATE_DISBMT_WORKFLOW if it's there in above permission object that it should return true else false what is

Slider not working in home component in Angular4 Web-App

拜拜、爱过 提交于 2019-12-24 19:04:33
问题 I have created web app using angular4. All pages working properly with routing. The default page is a home page. Slider working perfect in home page When the app is loaded after that slider not working when I go to another page and then coming into a home page. I have loads all external css and js into index.html page. In home component, load just content with slider and some scripts for slider load into the one-night method. Home page works properly when page refresh or load First time

Angular 2 ContentChild Apply Html Attributes

断了今生、忘了曾经 提交于 2019-12-24 16:41:49
问题 I have a custom component that applies bootstrap form group to my form fields. In my component I have below properties: import { Component, Input, ContentChild } from '@angular/core'; import { NgControl } from '@angular/common'; @Component({ selector: 'form-field', template: ` <div class="form-group" [ngClass]="{'has-error':(state && !state.valid && state.touched)}"> <label *ngIf="label" [attr.for]="state.name" class="col-sm-3 control-label">{{label}}</label> <div class="col-sm-9"> <ng