Last active
August 29, 2015 14:07
-
-
Save ovarunendra/84ce0722b3d527fbbb42 to your computer and use it in GitHub Desktop.
simple ng-include example
This file contains 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
/** | |
* Created by ovarunendra on 05-10-2014. | |
*/ | |
// Code goes here | |
angular.module('MyApp', []) | |
.controller('MainCtrl', [function() { | |
var self = this; | |
self.template = 'first.html'; | |
self.change = function(){ | |
self.template = 'second.html';; | |
}; | |
}]); |
This file contains 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
<h1>First Template</h1> | |
Name: <input type="text" ng-model="mainCtrl.name"></input> | |
<button ng-click="mainCtrl.change()">Save</button> |
This file contains 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> | |
<head> | |
<title>Sample App</title> | |
</head> | |
<body ng-app="MyApp"> | |
<div ng-controller="MainCtrl as mainCtrl"> | |
<div ng-include="mainCtrl.template"> | |
</div> | |
</div> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.js"></script> | |
<script src="app.js"></script> | |
</body> | |
</html> |
This file contains 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
<h2>Second Template</h2> | |
Name: {{mainCtrl.name}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment