I've been playing around with Angular 2 for the past few days and wondered if it was possible to provide a dynamic templateUrl
to the @View
decorator.
I have tried passing it a function and returning a string form it but the entire function just get's turned into a string.
I haven't really used Angular 1.x before either so I don't know if I'm just going about this in the wrong way, but is this possible, or is there a better way to create dynamic views?
For example I might want to display a form if the user is not logged in, but display a text message if they are logged in.
Something like this doesn't work:
@Component({
selector: 'my-component'
})
@View({
// This doesn't work
templateUrl: function() {
return this.isLoggedIn ? 'logged-in.html' : 'logged-out.html';
}
})
class MyComponent {
constructor() {
this.loggedIn = false;
}
}
Any help would be appreciated.