【问题标题】:AngularJS wont render into the html fileAngularJS 不会渲染到 html 文件中
【发布时间】:2016-11-03 00:55:43
【问题描述】:

谁能帮我找出我可能遇到的问题?

即使我已经导入了库,我似乎也无法使用 Angular。当我刷新 HTML 时,这就是浏览器中显示的内容。控制器似乎根本不工作。即使我尝试做 {{1+1}}。它不会为我做任何计算,而是只显示“{{1+1}}”。这已经困扰我三天了。真的很感谢有人可以给我一个提示。

这是我的 HTML 文件:

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

    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

    <meta charset ="utf-8">
    <meta http-equiv="X-UA-Compatible" content= "IE=edge">
    <title></title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
    <div class="container" ng-Controller="AppCtrl">
    <h1>UE Call Home</h1>
        <table class ="table">
            <thead>
                <tr>
                    <th>HostIP</th>
                    <th>IMSI</th>
                    <th>IMEI</th>
                    <th>Model</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat = "device in ue">
                    <td>{{device.hostid}}</td>
                    <td>{{device.imsi}}</td>
                    <td>{{device.imei}}</td>
                    <td>{{device.model}}</td>
                </tr>
            </tbody>
        </table>
    </div>
    <script type="javascript" src="Controller/controller.js"></script>
    <script type="javascript" src="angular.min.js"></script>
</body>

这是我的控制器:

var myApp = angular.module('myApp',[]);
myApp.controller('AppCtrl',['$scope','$http',function($scope,$http){
    console.log("Hello World!");
    ue1 ={
        hostip:"andrew",
        imsi:909090,
        imei:898989,
        model:8994
    };
    ue2 ={
        hostip:"nick",
        imsi:787878,
        imei:565656,
        model:8996
    };
    ue3 ={
        hostip:"dick",
        imsi:1212121,
        imei:2323232,
        model:9650
    };

    var ue =[person1,person2,person3];
    $scope.ue = ue;

}]);

【问题讨论】:

  • 你能把 ng-Controller 换成 ng-controller 吗?

标签: html angularjs node.js


【解决方案1】:

在你的 JavaScript 链接之前首先声明 Angular 链接

还有变量person1、person2、person3需要改成ue1、ue2、ue3

【讨论】:

  • 非常感谢。更改订单后它起作用了
【解决方案2】:

你必须改变&lt;script&gt;声明的顺序如下,

<script type="javascript" src="angular.min.js"></script>    
<script type="javascript" src="Controller/controller.js"></script>

还将 ng-Controller 替换为 ng-controller

除了验证angular.min.js路径外,最好将controller.jsangular.min.js放在同一个文件夹中以避免路径冲突。

【讨论】:

  • 欢迎您!如果你喜欢这个答案,请接受答案!
猜你喜欢
  • 2023-03-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-02
  • 1970-01-01
  • 2015-12-21
相关资源
最近更新 更多