javascript - Angular controller from imported module isn't working -


i trying use controller module imported in app controller callback function never invoked. missing here have been researching hours , can't figure out mistaken?

here's fiddle convenience : https://jsfiddle.net/06vz8bu8/

html

<main ng-app="itemlist" class="itemlist">             <div ng-repeat="item in items">       {{item.name}} : {{item.info}}     </div> </main>   

js

 var module = angular.module('itemlist', [    'itemlistcontrollers'  ]);   var ctrlmodule = angular.module('itemlistcontrollers', []);   ctrlmodule.controller = ('listcontroller', ['$scope'], function ($scope) {    $scope.items = [      {name: 'foo', info: 'moo'}    ];  }); 

appreciate kind help

what (see code comments):

 // .controller = ( <--- that????  // in addition, explicit injections using approach requires  // both injected service/provider names , function in same array  ctrlmodule.controller('listcontroller', ['$scope', function ($scope) {    $scope.items = [      {name: 'foo', info: 'moo'}    ];  }]); 

in html, need explicitly set controller using ng-controller directive unless use ui router or ngroute:

<main ng-app="itemlist" class="itemlist" ng-controller="listcontroller"> 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -