2014-02-28 45 views
2

我有一個簡單的頁面,我試圖使用JQuery Layout插件。該代碼是:JQuery Layout與AngularJS

<!DOCTYPE html> 
<html ng-app="app"> 

<head> 
    <title>Layout Example</title> 
</head> 

<body> 


    <div class="ui-layout-center"> 
     Angular test: 
     <input type="text" ng-model="name" />{{name}} 
    </div> 
    <div class="ui-layout-north">North</div> 
    <div class="ui-layout-south">South</div> 
    <div class="ui-layout-east">East</div> 
    <div class="ui-layout-west">West</div> 


    <script src="http://code.jquery.com/jquery-2.0.3.min.js"></script> 
    <script src="http://code.angularjs.org/1.2.13/angular.js"></script> 
    <script src="http://layout.jquery-dev.net/lib/js/jquery.layout-latest.js"></script> 

    <script type="text/javascript"> 
    var app = angular.module('app', []); 

    app.directive('body', function() { 
     return { 
     restrict: 'E', 
     link: function(scope, elm, attrs) { 
      console.log("applying layout"); 

      elm.layout({ 
      applyDefaultStyles: true 
      }); 
     } 
     }; 
    }); 
    </script> 

</body> 

</html> 

現在,當我嘗試來包裝UI佈局容器,沒有出現在屏幕上。不過,我可以在Web開發人員工具欄中看到佈局的完整代碼。代碼是:

<!DOCTYPE html> 
<html ng-app="app"> 

<head> 
    <title>Layout Example</title> 
</head> 

<body> 

    <div class="wrapper"> 
    <div class="ui-layout-center"> 
     Angular test: 
     <input type="text" ng-model="name" />{{name}} 
    </div> 
    <div class="ui-layout-north">North</div> 
    <div class="ui-layout-south">South</div> 
    <div class="ui-layout-east">East</div> 
    <div class="ui-layout-west">West</div> 
    </div> 

    <script src="http://code.jquery.com/jquery-2.0.3.min.js"></script> 
    <script src="http://code.angularjs.org/1.2.13/angular.js"></script> 
    <script src="http://layout.jquery-dev.net/lib/js/jquery.layout-latest.js"></script> 

    <script type="text/javascript"> 
    var app = angular.module('app', []); 

    app.directive('wrapper', function() { 
     return { 
     restrict: 'C', 
     link: function(scope, elm, attrs) { 
      console.log("applying layout"); 

      elm.layout({ 
      applyDefaultStyles: true 
      }); 
     } 
     }; 
    }); 
    </script> 

</body> 

</html> 

所以,看起來我無法正確傳遞類名稱。什麼應該作爲類名傳遞以使其工作?謝謝

編輯:您可以複製和粘貼Plunker中的代碼來查看問題。

回答

1

您對您的包裝需要height

<div class="wrapper" style="height:500px;"> 

我想它適用於<body>因爲<body>填充頁面。

0

不熟悉JS-Layout,但它看起來不喜歡包裝div(或任何其他包裝元素)。

這可能不是您正在尋找的答案,但您可以將課程設置爲正文,它將起作用。

http://plnkr.co/edit/l0ddGBcSZwTO18Q9RvBC