1

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>
2
  • you need to seperate the values like so: {{ Firstname }} {{ Friendname }} The + you have in there will actually try and evaluate whatever you have in there Commented Apr 13, 2016 at 22:35
  • 1
    {{ Firstname + " " + Friendname}} works and does output Neha Mayank and updates as expected when input are updated. So not sure what the question is here... Here's a working plnkr: plnkr.co/edit/LX8VpO5i7zVzovovc8Oo Commented Apr 13, 2016 at 22:57

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

Actually i have written that script was problem in copy paste sorry :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.