Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/404.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么angularjs不使用typescript显示值?_Javascript_Angularjs_Typescript - Fatal编程技术网

Javascript 为什么angularjs不使用typescript显示值?

Javascript 为什么angularjs不使用typescript显示值?,javascript,angularjs,typescript,Javascript,Angularjs,Typescript,我在introduction.html中有以下页面 <div ng-controller="IntroductionCtrl"> <h1>{{hello}}</h1> <h2>{{title}}</h2> </div> 我的主要模块在app.ts中: module app{ angular.module("app",[]); } 我的index.html是-> <!DOCTYPE html>

我在introduction.html中有以下页面

<div ng-controller="IntroductionCtrl">
  <h1>{{hello}}</h1>
  <h2>{{title}}</h2>
</div>
我的主要模块在app.ts中:

module app{
    angular.module("app",[]);
}
我的index.html是->

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Simple Tester</title>

    <!-- Style sheets -->
    <link href="bootstrap/bootstrap.css" rel="stylesheet" />
</head>
<body ng-app="app">

    <div class="container">
        <div ng-include="'/app/introduction/introduction.html'"></div>
    </div>


    <!-- Angular main libraries -->
    <script src="scripts/angular.js"></script>
    <script src="scripts/angular-animate.js"></script>
    <script src="scripts/angular-cookies.js"></script>
    <script src="scripts/angular-loader.js"></script>
    <script src="scripts/angular-mock.js"></script>
    <script src="scripts/angular-resource.js"></script>
    <script src="scripts/angular-route.js"></script>

    <!-- App scripts -->
    <script src="app/app.js"></script>

    <!-- Introduction -->
    <script src="app/introduction/introductionCtrl.js"></script>
</body>
</html>

简易测试仪
我想在introdction.html中显示“title”和“hello”的结果。为什么不显示?谢谢。

试试语法:


{{vm.hello}
{{vm.title}
您是在控制器本身上设置值,而不是在
$scope
上设置值,因此“controller as”语法可能是最好的选择

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Simple Tester</title>

    <!-- Style sheets -->
    <link href="bootstrap/bootstrap.css" rel="stylesheet" />
</head>
<body ng-app="app">

    <div class="container">
        <div ng-include="'/app/introduction/introduction.html'"></div>
    </div>


    <!-- Angular main libraries -->
    <script src="scripts/angular.js"></script>
    <script src="scripts/angular-animate.js"></script>
    <script src="scripts/angular-cookies.js"></script>
    <script src="scripts/angular-loader.js"></script>
    <script src="scripts/angular-mock.js"></script>
    <script src="scripts/angular-resource.js"></script>
    <script src="scripts/angular-route.js"></script>

    <!-- App scripts -->
    <script src="app/app.js"></script>

    <!-- Introduction -->
    <script src="app/introduction/introductionCtrl.js"></script>
</body>
</html>
<div ng-controller="IntroductionCtrl as vm">
    <h1>{{vm.hello}}</h1>
    <h2>{{vm.title}}</h2>
</div>