我正在构建一个小应用。其中一个步骤要求我创建一个具有自动完成功能的输入框。我正在使用Agular Material。
这是我的代码:
HTML:
<!DOCTYPE html>
<html lang="en" ng-app="myApp" ng-cloak>
<head>
<meta charset="utf-8">
<title>app</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular-aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular-messages.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc.5/angular-material.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc.5/angular-material.min.css">
<link rel="stylesheet" href="./style.css" type="text/css">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic, 700italic' rel='stylesheet' type='text/css'>
</head>
<body layout="column" ng-controller="autoCompleteController">
<h1>Purchase Order</h1>
<div>
<div class="row">
<md-autocomplete flex
md-selected-item="ctrl.selectedItem"
md-search-text="ctrl.searchText"
md-items="item in ctrl.querySearch(ctrl.searchText)"
md-item-text="item.name"
placeholder="Product name">
<span md-highlight-text="ctrl.searchText">{{item.name}}</span>
</md-autocomplete>
</div>
</div>
<script src="../src/api.js"></script>
</body>
</html>
和JS:
var myApp = angular.module('myApp', ['ngMaterial']);
myApp.controller('autoCompleteController', function($http, $scope) {
this.querySearch = function() {
return $scope.products
.then(function(result) {
$scope.autcomplete = response.data.name;
})
}
$scope.products = [
{name:"Worn Shortsword",price:3},
/* 4000 other products inbetween */
,{name:"Annealed Blade",price:12980}
];
});
我知道我的代码可能有一些问题和错误,因为我是Angular中的新手,但是每次我在输入框中输入一个字母时,控制台中显示的错误就是错误:
错误:r未定义 TE @ https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc.5/angular-material.min.js:14:2432 本身@ https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc.5/angular-material.min.js:14:3262 O /&LT; @ https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc.5/angular-material.min.js:14:16 E /&LT; @ https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:130:409 。VF /这$ gethttps://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:145:103 。VF /这$ gethttps://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:142:165 。VF /这$ gethttps://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:145:399 Pghttps://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:286:400 Pghttps://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:286:128 磅/升@ https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:176:478 SF @ https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:37:31 RF / d @ https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:36:486
这是什么意思?我无法找到有关此错误的任何信息。