javascript - I cannot show model values -
i have declared author inside scope variable
<!doctype html> <html lang="en" ng-app> <head> <meta charset="utf-8"> <title>angular demo</title> <script src="lib/angular/angular.min.js"></script> </head> <body> <div ng-controller="mycontroller"> <h1>{{author.name}}</h1> <p>{{author.title + ','+ author.company}}</p> </div> <script> function mycontroller($scope){ $scope.author = { 'name' : 'joe richard', 'title': 'android developer', 'company' : 'sunet technologies' } } </script> </body> </html>
but when try show values of author model, browser not showing values:
{{author.name}} {{ author.title + ', ' + author.company }}
what doing wrong? how show values need?
you need module , controller set properly:
<script> var app = angular.module('app', []) app.controller('mycontroller', function($scope){ $scope.author = { 'name' : 'joe richard', 'title': 'android developer', 'company' : 'sunet technologies' } }) </script>
in html tag make sure set ng-app="app". plunker demo
Comments
Post a Comment