I am building an app using Angular 2 with plain JavaScript and I can't find any example of how to use RouteConfig for JavaScript (not ts).
Can anyone give me an example of how to use. I tried like this but it's not working:
(function(app) {
app.MainComponent =
ng.core.Component({
selector: 'app',
templateUrl: 'app/components/main/main.view.html'
})
.Class({
constructor: function() {}
})
.RouteConfig([
{path: '/', redirectTo: '/job'},
{path: '/job', component: JobViewComponent }
])
;
})(window.app || (window.app = {}));
And I have other file that is JobView
(function(app) {
app.JobViewComponent =
ng.core.Component({
selector: 'job-view',
templateUrl: 'app/components/job_view/job_view.view.html'
})
.Class({
constructor: function() {}
});
})(window.app || (window.app = {}));
Thanks.
RouteConfig
is a decorator so you should use it this way:
app.MainComponent =
ng.core.Component({
selector: 'app',
templateUrl: 'app/components/main/main.view.html'
})
.Class({
constructor: function() {}
});
app.MainComponent = ng.core.RouteConfig([
{path: '/', redirectTo: '/job'},
{path: '/job', component: JobViewComponent }
])(app.MainComponent);
Here is a working plunkr: https://plnkr.co/edit/ZcSGHSsV8fBOc4TnI68h?p=preview .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.