AngularJs plunker不工作? Plunker新手

时间:2017-04-02 23:04:21

标签: angularjs plunker

我对plunker比较陌生,我做错了什么?控制台中存在错误,实时预览无效。代码在我的localhost中运行得非常好。

这是它的链接。 http://plnkr.co/edit/cZ48oeBBDthtVqXMRJPy?p=preview

    <html ng-app="myApp">

  <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.1/angular.min.js"></script>
    <script data-require="jquery@*" data-semver="3.1.1" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <script data-require="less.js@*" data-semver="2.6.1" src="https://cdnjs.cloudflare.com/ajax/libs/less.js/2.6.1/less.min.js"></script>
    <link rel="stylesheet" href="style.less" />
    <script src="script.js"></script>
  </head>

  <body ng-controller="mainCtrl">
    <div class="container">
      <!-- Parent scope -->
      <div class="">
        <div prevent="" visible="isVisible" object-data="objectData">
          <table class="datatable">
            <tbody>
              <tr ng-repeat="t in templateData">
                <td class="haseebtesting" ng-click="current.selected = t; confusedFunction(t)" id="{{'test ' + $index}}">{{t.templateName}}</td>
                <td>{{t.templatePath}}</td>
              </tr>
            </tbody>
          </table>
          <div ng-show="isVisible" class="parented">
            <form class="haseebform">
              <input type="text" ng-model="objectData.entername" placeholder="Enter name" />
              <br />
              <input type="text" ng-model="objectData.entercomment" placeholder="Enter comment" />
              <input type="button" class="btn btn-info" ng-click="addT(objectData)" value="Submit" />
            </form>
          </div>
        </div>
      </div>
    </div>
    <script src="script.js"></script>
  </body>

</html>

2 个答案:

答案 0 :(得分:2)

您需要将jquery脚本移动到angular脚本之上。当角度加载时,如果jquery不存在,则使用jqlite代替,即使随后加载了jquery。

答案 1 :(得分:2)

plnkr edit

我没有错误就开始了。

脚本代码:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/less.js/2.7.2/less.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.3/angular.min.js"></script>
<script src="app.js"></script>