I'm trying to implement iife and this style to seperate my files in angularjs so I have config.js that will use ui.router that was implemented this way
//config.js
(function (module) {
"use strict";
module.config([
"$stateProvider","$urlRouterProvider","$locationProvider",
function ($stateProvider, $urlRouterProvider,$locationProvider) {
$urlRouterProvider.otherwise("/Views/Profile.html");
$stateProvider
.state("profile", {
url: "/",
templateUrl: "Profile.html",
controller: "profileController as vm"
})
.state("profiledetails", {
url: "ProfileDetails",
templateUrl:"ProfileDetails.html",
controller: "profileController as vm"
})
}
])
})(angular.module("appMain", ["ui.grid","ui.router","profileService"]));
and I have this profile.html which has a link to profiledetail.html
<!DOCTYPE html>
<html ng-app="appMain">
<head>
<title></title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link href="../Content/ui-grid.css" rel="stylesheet" />
<link href="../Content/bootstrap.min.css" rel="stylesheet" />
</head>
<body class="container-fluid">
<div ng-controller="profileController">
<div id="profileGrid" ui-grid="gridOptions"></div>
</div>
<script src="../scripts/angular.js"></script>
<script src="../scripts/angular-ui-router.js"></script>
<script src="../scripts/angular-resource.js"></script>
<script src="../scripts/ui-grid.min.js"></script>
<script src="../scripts/App/config.js"></script>
<script src="../scripts/App/Profile/profileService.js"></script>
<script src="../scripts/App/Profile/profileController.js"></script>
<script src="../scripts/App/helper.js"></script>
<a href="#" ui-sref="profiledetails" class="btn btn-primary">profile details</a>
<div ui-view></div>
</body>
</html>
And this is my profilecontroller.js
(function(module) {
"use strict";
module.controller("profileController", ["$scope", "profileService", profileController]);
function profileController($scope, profileService) {
var vm = this;
var scope = $scope;
vm.profiles = getProfiles;
var onProfiles = [{
firstName: "Juan",
lastName: "Dela Cruz"
}, {
firstName: "Andres",
lastName: "Cruz"
}];
function getProfiles() {
profileService.getProfiles()
.then(onProfiles(result));
};
scope.gridOptions = {
enableSorting: true,
columnDefs: [{
name: "firstName",
field: "firstName"
}, {
name: "lastName",
field: "lastName"
}],
data: onProfiles
};
}
}(angular.module("appMain")));
In running the code and upon click to the link theres an error in chrome saying "Error: Could not resolve 'profiledetails' from state ''". Not sure if my implementation of iife caused this issue. Please someone guide me to the correct path.
})(angular.module("appMain", ["profileService", "ui.grid"]));