Last active
October 17, 2018 15:26
-
-
Save luillyfe/a541cc6d752464c49ed430a6ae65a3e6 to your computer and use it in GitHub Desktop.
Angular: props are immutable?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// App Component | |
export class AppComponent { | |
title="News title"; | |
content="A description should be here!"; | |
} | |
// News component | |
@Component({ | |
selector: 'news', | |
template: ` | |
<div> | |
<h1>{{title}}</h1> | |
<div>{{content}}</div> | |
<button (click)="mutateProps()">Mutate!</button> | |
</div> | |
`, | |
}) | |
export class NewsComponent { | |
@Input() title: string; | |
@Input() content: string; | |
mutateProps() { | |
this.title = "Title changed!"; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment