I am working on on angularjs app and we need to integrate with another angularjs app. On click of a button on first app modal window and its content should get it form app2. I am trying below approach but app2 controller/module is not getting initialized. Here is the error
Error: [ng:areq] Argument 'AppTwoCtrl' is not a function, got undefined
Here is the code snippet.
AppOneController.js
//first module/controller define(['main'], function(ng, main) { // we are using require.js and all controllers are declared in main.js angular.module('AppOne', ['ui.router', 'ui.bootstrap', 'ngRoute', 'ngAnimate']) .config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) { //stateprovider code $stateProvider.state('landing', { url: '/landing', templateUrl: '../landing/AppOne.html', controller: 'AppOneCtrl' }); } controller('AppOneCtrl', ['$scope', '$rootScope', 'inventorySvc', function($scope, $rootScope, inventorySvc) { console.log('in the controller') $scope.add = function () { var addVCGUrl = getBaseURL() + "/../../apptwo/landing/AppTwo.html"; var add_node_Modal = $modal.open({ templateUrl: addVCGUrl, size: 'sm', backdrop : 'static', resolve:{ //code here }, modalTitle: function () { // cod here } } }); }; }/landing/AppOne.html => html from the first app
<html ng-app="AppOne"> <div> <div ng-click="add()"> <div class="addVCG">Add</div> </div> </div> </html>- AppTwoController.js
// second module/controller
define(['main'], function(ng, main) { // we are using require.js and all controllers are declared in main.js
angular.module('AppTwo', ['ui.router', 'ui.bootstrap', 'ngRoute', 'ngAnimate'])
.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
//stateprovider code
$stateProvider.state('landing', {
url: '/landing',
templateUrl: '../landing/AppTwo.html',
controller: 'AppTwoCtrl'
});
}
controller('AppTwoCtrl', ['$scope', '$rootScope', function($scope, $rootScope) {
console.log('in the controller')
}
/landing/AppTwo.html
<!--html from the second app-->
<html ng-app="AppTwo">
<div>
You are in App2 module and apptwo controller
</div>
</html>
ng-appreference anywhere in your html?