angular2-template

Angular 2: Using a component in two diffrent ways: as target of a route and by selector <selector-my-component>

大城市里の小女人 提交于 2019-12-24 00:57:43
问题 This is a general question concerning Angular 2 (no source code here) In Angular2 components can be assigned as the target of a specific route of the router. The route /something/:myId might activate the "SomethingComponent". Meanwhile components can be pulled into other components by referencing the selector in the template like this: <something-component [myId]="'123'"></something-component> Is it ok to use one component in both ways? Can I distinguish within the component, how it was

Display image using angular 2

我只是一个虾纸丫 提交于 2019-12-24 00:24:01
问题 I am very new to angular 2 I am stuck here where i have to display an image for which I'm using relative path­­­­­­­­­­­­­­­­­­­­ <img src="./../images/publicVideo1.PNG"> but getting the below error null:1 GET http://localhost:4200/null 404 (Not Found) The above is the app structure where I have image in images folder which I'm trying to access from public-videos.component.html I dont understand where I'm wrong Any help would be appreciated. 回答1: create one dir assets in src directory. and

Embedding an Angular Directive in <tr>

老子叫甜甜 提交于 2019-12-23 23:12:07
问题 I'm trying to get an angular directive to repeat inside a <tr> . Without the directive, the code is <tr *ngFor='let cluster of clusters'> <td style='display: flex; flex-direction: column; width: 40%; min-width: 300px;'> <span>{{ cluster.Name }}</span> <span>{{ cluster.StatusMessage }}</span> </td> <td style='width: 100%;'> ... </td> </tr> And looks like When I refactor the directive, I lose the <tr> formatting. The refactored code is <tr *ngFor='let cluster of clusters'> <cluster-row [name]=

How do you run a function on the result of NgFor in Angular2?

江枫思渺然 提交于 2019-12-23 21:18:20
问题 Consider a list of all of the users in your system: allUsers = { a: {name:'Adam',email:'adam@testco.com',level:'admin',group:'Owners'}, b: {name:'Barbra',email:'Barbra@testco.com',level:'admin',group:'Owners'}, c: {name:'Chris',email:'Chris@otherplace.net',level:'standard',group:'Managers'}, d: {name:'Dennis',email:'dsmolek@showman.com',level:'standard',group:'Managers'}, e: {name:'Elizabeth',email:'eadams@testco.com',level:'standard',group:'Staff'}, f: {name:'fred',email:'fred@testco.com'

How can I use ngControl in contenteditable element?

烂漫一生 提交于 2019-12-23 18:50:31
问题 How can I use ngControl in contenteditable element? For example, I want: <!-- *ngFor over rows and columns in table --> <td contenteditable="true" [ngControl]="row.number + column.number"></td> With binding (?) it to model-driven "form" (table). I create him with formBuilder based on schema, that retrieve from server. Currently I think that doesnt work, 'cause <td> (and others) element haven't property value . Then, possible to overload some methods to work with textContent property? Or exist

click to remove/Deactivate Auxiliary Route in angular 2

主宰稳场 提交于 2019-12-23 16:31:43
问题 When I do click on compose button to open email template (e.g; as given in gmail when click to compose mail), using Auxiliary Route for multiple template in single page. Question is : how to remove or Deactivate this Auxiliary Route, when click on cross button. app.ts @RouteConfig([ { path: '/', name: 'OpportunityList', component: OpportunityComponent, useAsDefault: true }, { path: '/detail', name: 'Detail', component: DetailComponent }, { aux: '/mailer', name: 'Mailer', component:

parse Array in angular template

一个人想着一个人 提交于 2019-12-23 05:33:07
问题 somebody maybe encounter some situation when use the ngFor without collections.But seems looks like every one like to set the variable of array and let *ngFor binding like following code: array // typescript public bignumber:number[]=[1,2,3,4,5,6,7,8,9,10] //html <ng-template *ngFor="let item of bignumber | index as i"> p {{i}} <!-- would show ten times --> </ng-template> It's not friendly for template when you want to run 5 times or 10 times and you need to set the new varible then you can

ngFor not updating when @Input updated from google map marker event

孤人 提交于 2019-12-23 02:28:52
问题 I'm trying to build a simple app with angular2, I have the below component: @Component({ selector: 'map-menu', templateUrl: './angular-app/components/map-menu.html' }) export class MapMenuComponent { @Input() selectedMarkers: Array<google.maps.Marker>; constructor() { // setInterval(() => { // console.log(this); // }, 1000); } } when my map-menu.html is: <ul class="nav nav-sidebar"> <li *ngFor="#marker of selectedMarkers #i = index"><a href="#">{{marker.data.name}}</a></li> </ul> and in my

How do I get Angular 2/4 to update existing DOM nodes instead of deleting+creating them?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 12:22:29
问题 My Angular 4 application has a Component that has a refresh method that pulls-in a large object from my web-service, like so: DTOs/Model types: class NuclearReactorStatus { public reactorName: string; public coolingRods: CoolingRodStatus[]; // array of 1024 elements } class CoolingRodStatus { public rodId : number; public temperature: number; public status : string; } Inside the NuclearReactorDisplayComponent : public reactorStatus: NuclearReactorStatus; refresh(): void { this.http.get

How do I get Angular 2/4 to update existing DOM nodes instead of deleting+creating them?

强颜欢笑 提交于 2019-12-22 12:22:14
问题 My Angular 4 application has a Component that has a refresh method that pulls-in a large object from my web-service, like so: DTOs/Model types: class NuclearReactorStatus { public reactorName: string; public coolingRods: CoolingRodStatus[]; // array of 1024 elements } class CoolingRodStatus { public rodId : number; public temperature: number; public status : string; } Inside the NuclearReactorDisplayComponent : public reactorStatus: NuclearReactorStatus; refresh(): void { this.http.get