Sunday, 15 March 2015

angularjs - Can 1 html calls 2 different controller from 2 different external javascript? -



angularjs - Can 1 html calls 2 different controller from 2 different external javascript? -

i have html..

<body ng-app="buybye"> <div id='welcomebanner' ng-controller="1stcontroller"> </div> <div id="inputctrl" ng-controller="2ndcontroller"> </div>

then have 2 different javascript, 1 1stcontroller

var app = angular.module('buybye', []) app.controller('1stcontroller', function($scope) {}

and 1 2ndcontroller.

var app = angular.module('buybye', []) app.controller('2ndcontroller', function($scope) {}

but 1 controller works while other don't. because have 2 separate js files?

thanks.

it's happening because defining module buybye twice. instead should define once.

var app = angular.module('buybye', []) var app = angular.module('buybye', []) app.controller('1stcontroller', function($scope) {}); app.controller('2ndcontroller', function($scope) {});

angularjs angularjs-scope

No comments:

Post a Comment