My Application looks something like this (Screenshot). To Control the URL Routing i am using a Angular Js Router. On Click of Store of the Side Panel the StoreList Appears. And on Click of the Edit, the portion template gets fetched from Spring MVC and displayed along with the details. I have written the Code for app.js provided in the below part.

Because data could not be shared between the controllers i have written a StoreService and then the listStore array and its getters and setters so that same can be accessed via the controllers. This works fine but :-

  1. can there be a better code to this or any Angular functionalities i can use which can really simplify the code ? OR

  2. if i am not violating the rules of this forumn, can i directly ask is that the right way to code ?

  3. Was there anyway to use one single Controller for a logical module (like Store CRUD) ?

enter image description here

app.js :-

    var storezillaadminapp = angular.module('storezilla-admin',['ngRoute']);

            function($routeProvider) {
                    controller : "StoreZillaAdminListController"
                controller : "StoreZillaAdminEditController"


       var listStores = [];

        this.getAllStores = function() { 
            return $http.get(_contextPath+'/stores');

        this.getListStores = function() {
            return listStores;

        this.setListStores = function(data) {
            listStores = data;

            $scope.listStores = response;

    $scope.store = StoreService.getListStores()[$routeParams.id];


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.