ephemerr
ephemerr

Reputation: 1983

Combine ng-admin and ui-router

I have AngularJS(1.4.9) project that is build with usage of ui-router and have few states like this:

.state('overview', {
  url: '/overview',
  parent: 'dashboard',
  templateUrl: 'views/dashboard/overview.html'
})
.state('settings', {
  url: '/settings',
  parent: 'dashboard',
  templateUrl: 'settings/views/index.html',
  controller: "SettingsCtrl"
})

Now I want to add want to integrate ng-admin(0.9.1) to it. I have tested it as standalone app with standalone html as described in docs and it works. But I couldn't find a way to add it to current project.

Upvotes: 0

Views: 79

Answers (2)

ephemerr
ephemerr

Reputation: 1983

My 'just works' solution is to add to main project states external link of ng-admin:

  .state('database', {
      onEnter: function($window) {
          $window.open('/ng-admin/ng-admin.html', '_self');
      }
  })

Upvotes: 0

Neha Tawar
Neha Tawar

Reputation: 705

You will have to change your app parent state with ng-admin like below

// from
myApp.config(function ($stateProvider) {
    $stateProvider.state('send-post', {
        parent: 'main',
        url: '/sendPost/:id',
        params: { id: null },
        controller: sendPostController,
        controllerAs: 'controller',
        template: sendPostControllerTemplate
    });
});

// to
myApp.config(function ($stateProvider) {
    $stateProvider.state('send-post', {
        parent: 'ng-admin', // <= this has changed
        url: '/sendPost/:id',
        params: { id: null },
        controller: sendPostController,
        controllerAs: 'controller',
        template: sendPostControllerTemplate
    });
});

For reference please check updated document ng-admin

Upvotes: 1

Related Questions