I have two modules- App1 and App2. App1 has one controller, Main. App2 has 2 controllers, First and Second. I have a button in the template (mainTemp) of Main controller of App1. On the click of that button how do route to the template(firstTemp) of First controller in App1 module?
This is what my App2 module looks like-
angular.module('App1', ['ngRoute'])
.config(function ($routeProvider, $locationProvider) {
$routeProvider
.when('/first', {
templateUrl: '/Template/firstTemp.html',
controller: 'First'
})
.when('/second', {
templateUrl: '/Template/secondTemp.html',
controller: 'Second'
})
$locationProvider.html5Mode(false).hashPrefix('!');
})
.controller('First', function ($scope, $http, $location) {
$scope.savedata = function (employee) {
$scope.employees = "";
$http.post("/Data/AddEmployee", { empl: employee })
.success(function (result) {
$scope.employees = result;
$location.path('/second');
})
.error(function (result) {
alert(result);
});
}
})
.controller('Second', function ($scope,$http) {
})
And This is the template (mainTemp) of Main controller of App1 module-
<div ng-app="App2" ng-controller="Main">
<input type="button" value="submit" name="btnSave" ng-click="route_()" />
</div>
ng-appin the page. All modules other than main one must be injected as dependencies