Questions tagged [angular2-template]

For questions referencing Angular Template Syntax including: interpolation, input(property) bindings, output(event) bindings, two-way binding, local variables, star syntax, etc. This tag is specific to angular version 2.x and above

Tag content based loosely off Victor Savkin's Angular Template Syntax article

2856 questions
1
vote
1 answer

Angular2 add class to parent component on child event execution

I am working on a project using Angular2 and until now find it awesome! But on the other hand, I find some pretty simple tasks frustrating. Well, what I am trying to do is pretty simple: In my app I have a header component (reusable through all app)…
MorKadosh
  • 5,128
  • 3
  • 23
  • 34
1
vote
2 answers

Angular 2: Event not firing

I'm trying to fire an event when my component gets the logged user from a service because I would like to show the navigation bar only when a user is logged in. Here's my app.component code: import { Component, OnInit, EventEmitter, Input, Output }…
1
vote
0 answers

Angular2 template Print variable value without binding it

i'm trying to print a variable value without binding it with the binding syntax {{}}, because in my case i'm having an editable input and a second input of the default value, each time i edit the input the defaut value input change also with the…
Anna
  • 1,537
  • 5
  • 11
  • 15
1
vote
1 answer

angular 2 how to access a json returned in the template

i have a service that return data from the database. in the OnInit i call the service and pass it the parameter and get back the results: this._route.params .map(params => params['id']) .subscribe((id) => { this.title = id ? "Edit User"…
Ron
  • 317
  • 6
  • 20
1
vote
2 answers

angular2: Nested loops in templates without emitting HTML

My data looks something like this this.data = [[1,2,3], [4,5,6]]; and I'd like to put the each of the values 1..6 in a tag of a table. My problem is, that the outer loop needs to be within some kind of tag, but I don't want to spoil the HTML…
1
vote
1 answer

Angular2: property binding and side effects

So I have been reading the official documentation "template syntax of Angular2" angular.io here in the sub heading of property binding "Avoid side effects" i see these lines that i dont understand We can’t assign a value to anything in a property…
1
vote
1 answer

Pass data from child component to template in angular2

I've got two components - Home and Counter and I want to be able to increment template variable in Counter from Home. It doesn't work, except initialization - the variable is initialized to 17, but after that the increment doesn't…
Goranov
  • 296
  • 1
  • 2
  • 9
1
vote
2 answers

Angular: overriding a component's function

I'm new to Angular and part of my problem is that I don't know what exactly this falls under, so I don't know where to research. I'm building a save button component. This exists 10+ times throughout our app and has the same look and location in…
sup bro
  • 261
  • 8
  • 18
1
vote
1 answer

How to pass value that's being fetched asynchronously to a component's Input in Angular2

I am trying to pass a value to a component's input but the variable currentQuestion is being fetched asynchronously at the point the page first loads so understandably I get an undefined error. How…
user1275105
  • 2,123
  • 4
  • 27
  • 41
1
vote
0 answers

Angular2 Import component based on Id

I need to decide what component needs to be displayed based on backend response. Eg: i get this response from backend { plugin: { id = 'inputfieldWidgetV12' } data: { value = 'helloWorld' } } based on this I need to…
javadev28hu
  • 160
  • 1
  • 5
1
vote
1 answer

How to refer to a template by id in angular2?

I'm trying to find a way to refer to a file by using an unique name instead of a folder path. With absolute and relative path, if I move the components folder I have to refactor all the link. That is quite annoying also because by using gulp all the…
1
vote
1 answer

Issue with template-driven forms after adding "provideForms()" to my main.ts

I recently started migrating to model-driven forms instead of template-driven forms. I had to add a provideForms(), to my main.ts. Since then all my template driven forms raise exceptions such as: Reference "#firstNameForm" is defined several…
balteo
  • 20,469
  • 52
  • 196
  • 362
1
vote
1 answer

webpack: whole project structure shown on localhost:8080 instead of component template

(Pic is provided)So I have been following tutorial on webpack i followed instruction but when im hitting port 8080 im seeing this instead of component template, im using webpack-dev-server This is webpack.config.js var webpack =…
1
vote
1 answer

How to reset ViewContainerRef in angular2 after change Detection?

So I am working on this app in which I have used ViewContainerRef along with dynamicComponentLoader like below: generic.component.ts export class GenericComponent implements OnInit, OnChanges{ @ViewChild('target', { read: ViewContainerRef })…
Bhushan Gadekar
  • 12,317
  • 20
  • 77
  • 124
1
vote
0 answers

UglifyJsPlugin crashed Angular 2 app

I use webpack for build my app. That's part of code: if (isProd) { ... pluginsList.push(new webpack.optimize.UglifyJsPlugin()); ... } Error: Unexpected closing tag "a" (" class="row align-center">
Illorian
  • 1,164
  • 2
  • 11
  • 37
1 2 3
99
100