dart - AngularDart dynamically change the page title -
one of components pulls page title (and content) mongodb based off of route , stores title in instance variable of component's class. best way give mustaches in <title>
tag variable display such <title>site title | {{pagename}}</title>
? <title>
tag outside of scope of component. maybe controller fit use case i'm not sure state of controller directive or root object is. thought making service , injecting in both seems overkill. there better way this? thanks!
i ended making new component , service.
my simplified index.html
(pretty no changes):
<html ng-app> <title>site title</title> </head> <body></body>
service store 1 variable:
import 'package:angular/angular.dart'; @injectable() class global { string pagetitle; global(); }
and component selector of title:
library title; import 'package:angular/angular.dart'; import 'package:mypackage/service/global.dart'; @component( selector: 'title', template: 'site title | {{titlecomp.global.pagetitle}}', publishas: 'titlecomp', useshadowdom: false) class titlecomponent { final global global; titlecomponent(this.global); }
i injected global component , modified global.pagetitle
whenever new page loaded.
i love hear improvements or ways use root controller or root scope.
Comments
Post a Comment