ome*_*sbk 4 javascript angularjs
我开始学习AngularJS,所以我创建了两个html页面:
的index.html
<!DOCTYPE html>
<html ng-app="TodoApp" xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="Scripts/jquery-1.10.2.js"></script>
<script src="Scripts/bootstrap.js"></script>
<script src="Scripts/angular.js"></script>
<script src="Scripts/angular-resource.js"></script>
<link href="Content/bootstrap.css" rel="stylesheet" />
<script src="Scripts/app.js"></script>
<title>Angular Tutorial</title>
</head>
<body>
<div class="container">
<div ng-view></div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
和list.html
<input type="text" ng-model="test">
<h1>Hello: {{test}}</h1>
Run Code Online (Sandbox Code Playgroud)
app.js看起来像这样
var TodoApp = angular.module("TodoApp", ["ngResource"]).
config(function ($routeProvider) {
$routeProvider.
when('/', { controller: ListCtrl, templateUrl: "list.html" }).
otherwise({ redirectTo: '/' });
});
var ListCtrl = function ($scope, $location)
{
$scope.test = "testing";
};
Run Code Online (Sandbox Code Playgroud)
不幸的是,当我打开index.html页面时,它是空白的.可能是问题的原因是什么?
正如你提到的错误: -
1)在主页面中添加angular-route.js文件.
2)在angular main app中添加'ngRoute'依赖项.
Doc: - https://docs.angularjs.org/tutorial/step_07
| 归档时间: |
|
| 查看次数: |
134 次 |
| 最近记录: |