Created
June 13, 2011 12:56
-
-
Save vojtajina/1022724 to your computer and use it in GitHub Desktop.
Angular - binding title example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html xmlns:ng="http://angularjs.org" ng:controller="Main"> | |
<head> | |
<title ng:bind-template="Prefix: {{pageTitle}}"></title> | |
<script type="text/javascript" src="build/angular.js" ng:autobind></script> | |
<script type="text/javascript"> | |
function Main(){} | |
function Child(){} | |
</script> | |
</head> | |
<body> | |
<a href ng:click="$root.pageTitle = 'parent'">set title to parent</a> | |
<div ng:controller="Child"> | |
<a href ng:click="$root.pageTitle = 'child title'">set title to child</a> | |
</div> | |
<a href ng:click="partial='content.html'">load partial</a> | |
<ng:include src="partial">nothing loaded</ng:include> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is partial content, which sets title to partial... | |
<div ng:init="$root.pageTitle = 'partial'"></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This doesn't seem to work for Internet Explorer 8, I had to resort to setting $window.document.title from my controller.