首页 > 解决方案 > angularJS脚本文件在html中调用时不起作用

问题描述

仅呈现网页的 html 输出和 {{10 + 10}}。我不确定我做错了什么,但我猜这是我的视觉工作室项目中的一些设置类型问题。

(function () {
  var app = angular.module("ShipmentsHome", []);

  var EditShipmentsController = function ($scope) {
    $scope.message = "--Still need to create grid here--";
  };

  app.controller("EditShipmentsController", ["$scope", EditShipmentsController]);
}());

!DOCTYPE html>
<html>

<head>
  <title>Shipments Home</title>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.10/angular.min.js"></script>
  <script src="../../lib/home.js"></script>
</head>

  <body ng-app="ShipmentsHome" ng-controller="EditShipmentsController">
    <h1>Product Transfers</h1>
    <p>Create or modify a transfer below:</p>
    <div> {{message}}</div>
    <p>look above for message from controller</p>
    <h2>{{10 + 10}}</h2>



  </body>
</html>

我在控制台中没有看到任何错误。以下是我所看到的: 在此处输入图像描述

标签: htmlangularjs

解决方案


问题可能出在您的相对路径上。当我用实际的控制器脚本替换脚本源时,我得到了它。请检查您的路径并更正它。


推荐阅读