Installation
bower install --save angular-meta-title
including script file provided by bower component sprintf
into your application
including angular-meta-title.js
script file provided by this component into your application
adding l42y.meta.title
as a module dependency to your application
Usage
Configuration
angular .module (' App' , [
' l42y.meta.title'
]).config (function (
TitleProvider
) {
TitleProvider .config ({
name: ' Site name' ,
slogan: ' Site slogan' ,
format: ' %(name)s · %(slogan)s'
});
}).config (function (
$routeProvider
) {
$routeProvider .when (' /about' , {
title: {
page: ' About' ,
format: ' %(page)s · %(name)s'
},
controller: ' AboutCtrl' ,
templateUrl: ' views/pages/about.html'
});
}).controller (' GlobalCtrl' , function (
Title
) {
this .title = Title;
}).controller (' AboutCtrl' , function (
Title
) {
Title .set ({
page: ' 关于'
format: ' %(page)s'
});
});
Binding
<html ng-app =" App" ng-controller =" GlobalCtrl as g" >
<head >
<title ng-bind =" g.title.content" >Site name</title >
</head >
</html >
License
WTFPL