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

3
  • possible duplicate of Simple example doesn't work on JSFiddle Commented 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 duplicate Commented 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". Commented Oct 13, 2014 at 6:05

1 Answer 1

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>

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

2 Comments

If it worked, mark the question as answered please. That way people know that it's solved and points can be received.
Sure.. Was waiting for the minimum time for marking the answer :-) @A.Alger

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.