I'm starting to learn Angular JS, and I wrote the following code to display name, age and profession. I'm using Angular 1.5.
<!-- View -->
<div ng-controller="MyController">
<h1> {{author.name}} </h1>
<p>{{author.age + " " + author.profession}}</p>
</div>
<!-- MODAL -->
<script>
function MyController($scope) {
$scope.author = {
'name': 'Muhammad',
'age': '35',
'profession': 'Software Engineer'
}
}
</script>
You need to add a module:
var app = angular.module("main", []);
app.controller("MyController", MyController);
<html ng-app="main">
<div ng-controller="MyController">
<h1> {{author.name}} </h1>
<p>{{author.age + " " + author.profession}}</p>
</div>
</html>
working example: http://codepen.io/nilestanner/pen/YWmWNo