0

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

Aneesh Mohan
  • 1,077
  • 8
  • 17
  • possible duplicate of [Simple example doesn't work on JSFiddle](http://stackoverflow.com/questions/5431351/simple-example-doesnt-work-on-jsfiddle) – JJJ Oct 13 '14 at 05: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 duplicate – Zach Oct 13 '14 at 06: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 Oct 13 '14 at 06:05

1 Answers1

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>

Amir Popovich
  • 29,350
  • 9
  • 53
  • 99