angular-meta-title

<title> as an AngularJS component


Keywords
angular
License
WTFPL
Install
bower install angular-meta-title

Documentation

angular-meta-title

Installation

  1. bower install --save angular-meta-title
  2. including script file provided by bower component sprintf into your application
  3. including angular-meta-title.js script file provided by this component into your application
  4. 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