twitter bootstrap - angularJs - Getting output like this {{student.fullname();}} in my code -
i trying run simple code not working. getting {{student.fullname();}}.
can me out ?
<!doctype html> <html> <head> <meta charset="iso-8859-1"> <title>angular</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body> <div ng-app="mainapp" ng-controller="studentcontroller"> firstname : <input type="text" class="form-control" ng-model=student.firstname/> <br> <br> lastname :<input type="text" class="form-control" ng-model=student.lastname/><br> <br> fullname : {{student.fullname()}}</div> <script> var mainapp= angular.module("mainapp",[]) mainapp.controller('studentcontroller',function($scope){ $scope.student={ firstname="hariharan", lastname="sriram", fullname=function(){ var obj; obj=$scope.student; return student.firstname" + "student.lastname; }; }); </script> </body> </html>
your script seems wrong in syntax. not defining javascript:
$scope.student = { firstname: "hariharan", lastname: "sriram", fullname: function() { var obj; obj = $scope.student; return obj.firstname + " " + obj.lastname; } }; you can directly in html view (another solution):
your fullname : {{student.firstname + ' ' + student.lastname}}</div> in way, don't have write piece of javascript.
Comments
Post a Comment