Skip to content

Instantly share code, notes, and snippets.

@kaunjovi
Created September 13, 2016 15:47
Show Gist options
  • Save kaunjovi/1fd4bb942628fd2c41c88d4c5b4dd8bd to your computer and use it in GitHub Desktop.
Save kaunjovi/1fd4bb942628fd2c41c88d4c5b4dd8bd to your computer and use it in GitHub Desktop.
Overriding $scope.variable by HTML, over the value set by JS.
<html>
<head>
<title>Hello world from Angular</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>
</head>
<body>
<h1>Hello world from Angular</h1>
<div ng-app="myApp" ng-controller="myController" ng-init="message='Over written.'">
<!--This message, instead of being hello world from controller, is overwritten -->
<h2>{{ message }} </h2>
</div>
</body>
<script>
angular.module('myApp', [])
.controller('myController', function( $scope ){
$scope.message = 'Hello world from AngularJs.' ;
}) ;
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment