De-Coder
De-Coder

Reputation: 21

Problems of Controller in AngularJs

I am new to Angular Js and i have just done basic tags of angularjs and when i started controller part i understood the concept but was unable to fetch data input by user..Please guide me so that i can take one step further in AngularJS

Thanks in Advance!!

<!DOCTYPE html>
<html>
<head></head>
<body>
<div ng-app="nehaApp" ng-controller="Mayank">
Name : <input type="text" ng-model="Firstname">
Friends : <input type="text" ng-model="Friendname">

 {{  Firstname  + "  "  +  Friendname}} 

</div>

<script>

var appname = angular.module('nehaApp',[]);

appname.controller('Mayank',function($scope)
{
   $scope.Firstname = "Neha"; 
   $scope.Friendname = "Mayank";
});
</script>
</body>
</html>

Upvotes: 1

Views: 53

Answers (2)

Jesus
Jesus

Reputation: 165

Ronnie comments says, you can see in my form example >>> https://plnkr.co/edit/n5qyRJ

Change your code:

{{  Firstname  + "  "  +  Friendname}} 

By this:

{{Firstname}} {{Friendname}} 

Seeya! Jesus

Upvotes: 2

pparas
pparas

Reputation: 549

You have to include the following line of code in you HTML.

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js"></script>

This will import the angular library into your page.

This library is what allows you to have the angular directives,modules and controllers in your code.

Hope that helps.

Thanks, Paras

Upvotes: 0

Related Questions