Tuesday, April 21, 2015

Angularjs use javascript file for controlller and write function

<html>
<title> AngularJs Directives </title>

<body>

<div ng-app="" ng-controller="firstController">

<ol>

{{ 'firstname: ' + data.firstname + ', lastname: ' + data.lastname }}
{{ data.fullName() }}

</ol>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>

<script src="main.js">

</script>

</body>
</html>



////////////////////////main.js///////////////////////

function firstController($scope)
{
$scope.data={
firstname:'shekhar',
lastname:'nawale',
fullName:function()
{
var studentObject;
studentObject=$scope.data;
return studentObject.firstname + " " +studentObject.lastname;
}
};
}

No comments:

Post a Comment