I want to act like Tiles on AngularJS' ui-router.

Asked 1 years ago, Updated 1 years ago, 63 views

I am using ui-router in AngularJS, but I would like to control the configuration of the screen like Tiles in Java.

Multiple screen functions exist, and multiple common parts functions exist as well.
To determine which common parts are displayed for a particular screen feature, see
I'd like to manage it with JSON files.

Consider using part C on each screen when there are screens A and B.
In the $stateProvider#state setting on screen A, if you define part C in view,
I know it can be seen in ui-view, but
I think this method will also require setting the $stateProvider#state on screen B.

Apart from the settings on screens A and B, I only set the state settings on part C.
I was wondering if I could include it on each screen, but I don't know how to do it.

Now I include it with ng-include, but with this method,
Due to other reasons, it will be difficult to change the controller of part C, so I wonder what I should do...

Additional

If you want to library parts and use them from different apps, If you want to change the controller for each application,
ng-include requires the controller to be
in the target HTML. It is listed and cannot be realized.

Library Side

angular.module('lib').config(function(){
  $stateProvider.state('partsState', 
    {url:'...', templateUrl:'hoge.html', controller:'orgCtrl'});
});

Application side

angular.module('app', [lib])..run(function($state){
  $state.get('org').controller='customCtrl';
});

javascript angularjs

2022-09-30 19:11

1 Answers

I'd like to set it up in the UI-Router, but now I'm using ng-include, but
For me, it seemed best to create a custom directive and solve it.

It will be difficult to change the controller of part C, so I don't know what to do...

I was a little confused about what this means, but I think the custom directive is like a set of controllers and templates, so it's just right for defining parts.

As I can imagine, part C is intended to be defined separately from screen A and screen B in order to function independently of screen A and screen B like widget (ya, portlet), but I don't know what I want to do because it doesn't connect with the path.

If you have a sample that says $stateProvide.state(...) like this,
You may understand a little more.


2022-09-30 19:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.