I have toggle button on the page, once its clicked, then the current page view would change to different html.
I have tired changing @Page
, but once its loaded, I can't seem to change it again.
@Page({
templateUrl: isTrue ? 'build/pages/detail/page-by-page-view.html' : 'build/pages/detail/chapter-by-chapter-view.html'
})
@Page()
is an annotation. Angular2 processes this upon loading of the component (which @Page()
technically is). It is not part of Zone change detection, so changing a variable won't do a thing. Not even after calling applicationRef.tick()
.
A solution could be to use an *ngIf
directive and merge your template files
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.