Search code examples
angularjsjsfiddle

Can someone tell me why this simple angularjs jsfiddle not working?


Can someone tell me why this simple angularjs jsfiddle not working?

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

myApp.controller('MyCtrl', ['$scope', function MyCtrl($scope) {
    $scope.name = 'Superhero';
}]);

and

<div ng-app="myApp" ng-controller="MyCtrl">

    Hello, {{name}}!

</div>

results in

Hello, {{name}}!

https://jsfiddle.net/cbdrow8u/1/


Solution

    1. Remove ng-app="myApp" from the div tag.
    2. Click the gear icon in the top right corner of HTML and in the BODY TAG field enter <body ng-app="myApp">.
    3. Click the gear icon in the top right corner of JavaScript and in the LOAD TYPE select No wrap - in <body>
    4. Click Update then Run.
    5. Profit!