Hi here is my angular js code. I am a complete novice in angular development.
<div ng-app="">
<input type="text" ng-model="firstname">
<input type="text" ng-model="lastname">
<p>Firstname : <span ng-bind="firstname"></span>
</p>
<p>Lastname :<span ng-bind="lastname"></span>
</p>
<p>Full name :<span>{{firstname +" "+lastname}}</span>
</p>
</div>
You can find the fiddle here
If I don't add the ng-controller directive the whole thing works. But when I adds the directive the whole thing stops working and the controller function is not getting executed.
Actually I am trying something similar to this
asked Oct 13, 2014 at 5:52
Aneesh Mohan
1,0878 silver badges17 bronze badges
-
possible duplicate of Simple example doesn't work on JSFiddleJJJ– JJJ2014年10月13日 05:55:58 +00:00Commented Oct 13, 2014 at 5:55
-
Root cause might be the same. But that might not be the thing which comes first to the mind of someone learning something new. It might become useful for someone in future. Can't say duplicateZach– Zach2014年10月13日 06:02:33 +00:00Commented Oct 13, 2014 at 6:02
-
2@Sachu Even if the question is marked duplicate, it doesn't mean it will be deleted. It will be even more useful for someone in the future if they can follow the link to the "root cause".JJJ– JJJ2014年10月13日 06:05:45 +00:00Commented Oct 13, 2014 at 6:05
1 Answer 1
JSFiddle has a Code Wrap drop-down with a default setting to "onLoad".
The drop down has 4 options:
onLoad: wrap the code so it will run in onLoad window.eventonDomReady: wrap the code so it will run in onDomReady window event.no wrap - in <head>:do not wrap the JavaScript code, place it in section.no wrap - in <body>:do not wrap the JavaScript code, place it in section.
Here's the documentation.
Here's your working code after I've changed the onload to no wrap - in <body>
answered Oct 13, 2014 at 5:55
Amir Popovich
30.1k9 gold badges58 silver badges102 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
Dr G.
If it worked, mark the question as answered please. That way people know that it's solved and points can be received.
Aneesh Mohan
Sure.. Was waiting for the minimum time for marking the answer :-) @A.Alger
lang-js