angular2-inputs

@Input and other decorators and inheritance

泄露秘密 提交于 2020-01-11 08:19:10
问题 I don't really understand how object binding works, so if anyone could explain if I can use @Input() inside a base class, or better: decorators and inheritance. For example if each form should receive a customer I have a base class: export class AbstractCustomerForm{ @Input() customer; ... } and then I extend this class in an actual component: export AwesomeCustomerForm extends AbstractCustomerForm implements OnInit{ ngOnInit(){ if(this.customer) doSomething(); } } but this won't work,

Should Angular2 @Inputs be public or can/should we have a stricter API by making them private?

前提是你 提交于 2019-12-22 04:14:11
问题 I am using Angular2 with Typescript Suppose I have the following in my app component's template: ... <coffee-cup [coffee]="" ... My coffee-cup component: @Component({ selector: 'coffee-cup', ... }) export class CoffeeCup { @Input() public coffee = 0; } I am currently unsure of what my Input should look like. It could look like this: @Input() public coffee = 0; Or @Input() private coffee = 0; I am currently leaning towards making the member variable coffee private. I want to define a clear

Angular @Input is not working with bootstrap component

[亡魂溺海] 提交于 2019-12-11 03:17:50
问题 I did a mistake in my Angular2 class and I've not clearly understood about @Input . I created 2 components AppComponent and AppDetailComponent. In AppDetailComponent : import { Component, Input } from '@angular/core'; @Component ({ selector: 'app-detail', template: 'Hi {{datainput}}' }) export class AppDetailComponent { @Input() datainput: string; } and in AppComponent template : <h1> {{title}} </h1> <app-detail [datainput]="'test'"></app-detail> and in App Module I made a mistake by add

Uncaught Reference Input is not defined- @Input() not working in Angular 2

倾然丶 夕夏残阳落幕 提交于 2019-12-10 19:01:01
问题 I am a newbie trying to learn Angular2 from ng-book 2(v49). Here are the contents of article.componenets.ts file: import { Component, OnInit } from '@angular/core'; import { Article } from './article.model'; @Component({ selector: 'app-article', templateUrl: './article.component.html', styleUrls: ['./article.component.css'], host: { class: 'row' } }) export class ArticleComponent implements OnInit { @Input() article: Article; voteUp(): boolean { this.article.voteUp(); return false; } voteDown

Update parent component property from child component in Angular 2

余生颓废 提交于 2019-11-27 17:57:20
I'm using @input to receive a property from parent component in order to activate a CSS class in one of child component's element. I'm able to receive the property from parent and also activate the class. But this works only once. The property i'm receiving from parent is a boolean data typed and when I set the status of it to false from child component, it does not change in parent. Plunkr: https://plnkr.co/edit/58xuZ1uzvToPhPtOING2?p=preview app.ts import {Component, NgModule} from '@angular/core' import {BrowserModule} from '@angular/platform-browser' import { HeaderComponent } from '.

Update parent component property from child component in Angular 2

白昼怎懂夜的黑 提交于 2019-11-26 12:56:02
问题 I\'m using @input to receive a property from parent component in order to activate a CSS class in one of child component\'s element. I\'m able to receive the property from parent and also activate the class. But this works only once. The property i\'m receiving from parent is a boolean data typed and when I set the status of it to false from child component, it does not change in parent. Plunkr: https://plnkr.co/edit/58xuZ1uzvToPhPtOING2?p=preview app.ts import {Component, NgModule} from \'