Comments (3)
When you say directive, and what your code looks like here, indicates to me that you're using Angular. If so, you should look at their Angular examples. I started with that and converted it to load the state and container into the scope. Then I compile the directive with the scope. This is much better than re-initializing Angular each time. For the AngularComponent piece, I have this:
var AngularModuleComponent = function( container, state ) {
// Get the Angular and Module injectors, the latter is required so
// that the $compile method can find the Angular components in those modules.
var $injector = angular.injector(['ng', 'MyApp']),
$compile = $injector.get('$compile'),
$rootScope = $injector.get('$rootScope');
// The template is super-simple... it just invokes the directive.
var html = "<" + state.directive + "></" + state.directive + ">",
element = container.getElement();
// Compile the DOM to initialize the directive. The Golden Layout container
// and state are passed on the scope into the directive.
var scope = $rootScope.$new();
scope.container = container;
scope.state = state;
element.html($compile(html)(scope));
};
This avoids bootstrapping Angular for each component, also allowing you to specify your ng-app
in the body element if you want. You'll need to compile your Angular templates using something like grunt-angular-templates
ahead of time. Then you can set up one of your components like so:
angular.module('MyApp')
.controller('LoginController', LoginController)
.directive('login', ['$templateCache', function($templateCache) {
return {
restrict: 'E',
replace: true,
template: function() {
return $templateCache.get('wwwroot/js/templates/login.html');
},
controller: LoginController
}
}]);
Hopefully this helps you out!
from golden-layout.
Thanks @bfattori I will give this a try.
from golden-layout.
Thanks @bfattori. Your solution worked. I have to tweaked the module as I have implemented main module a bit differently. But rest everything went well. :)
from golden-layout.
Related Issues (20)
- No header controls in basic implementation HOT 3
- Bugs in negated `instanceof` expressions
- Unable to add child items
- How i can remove created DragSources?
- Popouts are not handled in loadLayout correctly
- popout not working when using with popoutWholeStack enabled
- The position when closing the tab when reopening it HOT 1
- Way to prevent tab drag to other component [HELP] HOT 1
- RTL Feature Support HOT 1
- isClose cause issue with dragging
- X3D content fails after dragging window
- Is it possible to simulate a new window on this page instead of using the browser implementation?
- it popout the whole application gets loaded in popup window
- Error: Component type not registered and BindComponentEvent handler not assigned HOT 1
- newDragSource() does not work HOT 12
- I think the drag and drop method in the dev version is particularly good, but it seems that it cannot be used yet HOT 10
- Stack sizing not applied HOT 1
- Container content persists after dragging parent down
- Is it possible to update the containers while dragging the splitters?
- golen-layout blazor version
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from golden-layout.