natecraft1
natecraft1

Reputation: 2846

trying to define controller with module in angular

I don't know what's wrong here. An explanation would be lovely. Thanks!

http://jsfiddle.net/natecraft/xKtwP/13/

<body data-ng-app="channelApp">
  <div data-ng-controller="channelController">
    Hello! {{ name }}
  </div>
</body>

var mod = angular.module("channelApp", []);
mod.controller = ("channelController", function($scope) {
$scope.name = "nate"; 

});

Upvotes: 0

Views: 91

Answers (1)

Adam
Adam

Reputation: 5246

There are two separate issues causing this unexpected behavior. First, the syntax for the controller should be like this:

var mod = angular.module("channelApp", []);
mod.controller("channelController", function($scope) {
   $scope.name = "nate"; 

});

Second, the fiddle is setup incorrectly and still won't render properly after making the above fix. I have fixed the fiddle configuration in this forked version of your fiddle.

I also created the code example in CodePen for further reference.

Upvotes: 1

Related Questions