在视图中显示AngularJS内容

时间:2016-07-18 15:37:32

标签: javascript angularjs ng-view angularjs-ng-include ng-app

当我将以下静态HTML与视图一起使用时,一切都按预期工作,如下所示: https://embed.plnkr.co/MJYSP01mz5hMZHlNo2HC/

现在我要问的是,如何在ng-view中正确地使这个angular-ui手风琴正常工作?

请参阅我在这里尝试使用的手风琴:

http://plnkr.co/edit/1ZWBsbO6sQRnZ7CpPrdz?p=info

我的测试插件在这里,显示HTML显示在视图中,但它缺少JS功能: https://plnkr.co/edit/I3myvfH5KUkpfV1aWh72?p=info

<!DOCTYPE html>
<html>

  <head>
    <script data-require="angularjs@1.5.7" data-semver="1.5.7" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>
    <script data-require="angular-route@1.4.8" data-semver="1.4.8" src="https://code.angularjs.org/1.4.8/angular-route.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular-animate.js"></script>
    <script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.3.3.js"></script>
    <script src="script.js"></script>
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
  </head>

<body ng-app="Test">

    <div ng-include='"header.html"'></div>
    <div ng-view></div>
    <div ng-include='"footer.html"'></div>

</body>

</html>

1 个答案:

答案 0 :(得分:0)

您必须使用您定义的名称(PageCtrl)定义controller

app.controller('PageCtrl', [function(){  
 // Your business logic
 alert("In am controller"); 
 }])