A Pen by Julie Huynh on CodePen.
Created
April 27, 2015 01:32
-
-
Save huynj316/2af2ddc523035be2c8f7 to your computer and use it in GitHub Desktop.
jPEBwY
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
<html> | |
<head></head> | |
<body ng-app="myApp"> | |
<h2> {{title}} </h2> | |
<div ng-controller="HomeCtrl"> <!--specify controller--> | |
<h4>This is home page</h4> | |
<h5>Welcome back {{user}}</h5> | |
<input type="text" ng-model="inputMsg"> | |
<p ng-class="{'red': inputMsg.length > 6, 'green': inputMsg.length >10}">You just typed:{{inputMsg}} </p> | |
<p ng-style= "{'font-size': inputMsg.length*2 + 'px', opacity: inputMsg.length*.1, color: rgb( '+ inputMsg.length, 100, 100)}">{{inputMsg}}</p> | |
<button ng-click="sayHello(inputMsg)">Say Hello</button> | |
</div> | |
<div ng-controller="BlogCtrl"> | |
<h4>This is blog page</h4> | |
<!-- <h5>{{greeting}}</h5>--> | |
</div> | |
</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
angular.module('myApp', []) // keep dependencies | |
.run(function($rootScope) { //what gets called first | |
console.log('App Init'); | |
$rootScope.title = 'My Awesome Website'; | |
}) | |
//Binding Controller | |
.controller("HomeCtrl", function($scope, $rootScope) { | |
$scope.user = 'Apon'; | |
$scope.sayHello = function(msg) { | |
$rootScope.greeting = msg; | |
}; | |
}) | |
.controller("BlogCtrl", function($scope, $rootScope) { | |
}) |
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
.red { | |
color: red; | |
} | |
.green { | |
color: green; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment