我正在尝试将jQuery Layout 插件合并到我的 AngularJS 项目中。
我有一个工作版本,我只使用 jQuery、jQuery-UI 和 jQuery 布局插件在这里构建
现在我想在 AngularJS 中有同样的东西。
我特别难以将默认值传递给插件的嵌套实例。
一个简单的例子是这样工作的:
HTML:
<body ng-app="myApp">
<div id="outer-container" layout-container>
<div class="ui-layout-west pane">WEST</div>
<div class="ui-layout-center pane">MIDDLE</div>
<div class="ui-layout-east pane">EAST</div>
</div>
</body>
JavaScript:
var app = angular.module('myApp', []);
app.directive('layoutContainer', function() {
return {
scope: {},
link: function (scope, element, attrs) {
var layout = element.layout({
west: {
resizable : true,
initClosed : false,
livePaneResizing: true,
size: 150
},
east: {
resizable : true,
initClosed : false,
livePaneResizing: true,
size: 150
}
});
}
}
});
但是,当我这样做时,我尝试复制的示例不起作用:
HTML:
<body ng-app="myApp">
<div id="outer-container" layout-container>
<div class="ui-layout-west pane">WEST</div>
<div class="ui-layout-center pane">
<div id="middle-container" layout-middle>
<div class="ui-layout-north pane top-panel">
<div id="top-container" layout-top>
<div class="ui-layout-center pane">TOP LEFT</div>
<div class="ui-layout-east pane">TOP RIGHT</div>
</div>
</div>
<div class="ui-layout-center pane bottom-panel">
<div id="bottom-container" layout-bottom>
<div class="ui-layout-center pane">BOTTOM LEFT</div>
<div class="ui-layout-east pane">BOTTOM RIGHT</div>
</div>
</div>
</div>
</div>
<div class="ui-layout-east pane">EAST</div>
</div>
</body>
JavaScript:
var app = angular.module('myApp', []);
app.directive('layoutContainer', function() {
return {
scope: {},
link: function (scope, element, attrs) {
var layout = element.layout({
west: {
resizable : true,
initClosed : true,
livePaneResizing: true,
size: 350
},
east: {
resizable : true,
initClosed : true,
livePaneResizing: true,
size: 350
}
});
}
}
});
app.directive('layoutMiddle', function() {
return {
scope: {},
link: function (scope, element, attrs) {
var layout = element.layout({
north: {
size: .5,
livePaneResizing: true
}
});
}
}
});
app.directive('layoutTop', function() {
return {
link: function (scope, element, attrs) {
angular.element(element).layout({
east: {
size: .5,
livePaneResizing: true
}
});
}
};
});
app.directive('layoutBottom', function() {
return {
link: function (scope, element, attrs) {
angular.element(element).layout({
east: {
size: .5
}
});
}
};
});
我的目标是让 panel TOP LEFT
、TOP RIGHT
和默认情况BOTTOM LEFT
下BOTTOM RIGHT
平均占用所有空间。
编辑:问题在于指令是异步编译的。AngularJS顺序编译指令的正确方法是什么[在这种情况下,layoutContainer必须是第一个,然后是layoutMiddle,然后是剩下的layoutTop和layoutBottom]?