Simple AngularJS example with a module and controller in jsFiddle

angularjs, javascript, jsfiddle

Solution

Take a look at this article for some info about jsFiddle with Angular

Also more examples on AngularJS Wiki that you could use: https://github.com/angular/angular.js/wiki/JsFiddle-Examples

Problem

This probably a combo jsFiddle/Angular question, but I'm trying to learn me some basic Angular and I'm not sure why it only works when I include the controller JS in the HTML pane. jsFiddle here Basically the following works: ``` <div ng-app="myAppModule" ng-controller="someController"> <!-- Show the name in the browser --> <h1>Welcome {{ name }}</h1> <p>made by : {{userName}}</p> <!-- Bind the input to the name --> <input ng-model="name" name="name" placeholder="Enter your name" /> </div> <script> var myApp = angular.module('myAppModule', []); myApp.controller('someController', function($scope) { // do some stuff here $scope.userName = "skube"; }); </script> ``` But if I try to move the JS within the script tag to the JavaScript pane, it fails.

Original source