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
Post a Comment