Angular.JS ng-model

时间:2015-05-20 00:14:15

标签: javascript jquery angularjs

我有这段代码:

HTML

<!doctype html>
<html ng-app=EmployeeApp>
<head>
<meta charset="utf-8">
<title>favly</title>
<link rel="stylesheet" type="text/css" href="css/styles_index.css"/>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<link href='http://fonts.googleapis.com/css?family=Roboto:500,900,100,300,700,400' rel='stylesheet' type='text/css'>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.17/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="js/search_folder.js"></script>
</head>

<body ng-controller="empCtrl">
    <div id="leftMenu">
    	<div id="searchFoldersList"><span class="icon-search search"></span><input ng-model="fold.Folder" type="text" placeholder="Search..." /></div>
    	<div id="foldersList">
        	<ul>
                <li ng-repeat="fold in folder">{{fold.Folder}}</li>
            </ul>
        </div>
    	<div id="addFolderBox"><span class="icon-add plus"></span> ADD NEW FOLDER</div>
    </div>
    <div id="rightContent">
        <div id="menuContent">
        	<ul>
            	<li><span class="icon-list"></span></li>
                <li><span class="icon-settings"></span></li>
                <li><span class="icon-account-circle"></span></li>
            </ul>
        </div>
    </div>
</body>
</html>

这就是JS:

  var employeeApp = angular.module("EmployeeApp",[]);
  employeeApp.controller("empCtrl",function($scope, $http){
	  $http.get("folders_list.php").success(function (response) {$scope.folder = response.folders;});             
  });

而folders_list.php的范围是:

{ “记录”:[{ “文件夹”: “JUEGOS”},{ “文件夹”: “Periféricos”}]}

好我的代码工作并显示文件夹的名称,但我的问题是我不知道为什么输入不搜索那些“li”来找到输入的单词。我认为这是因为我的ng模型不正确,但我不知道什么是ng-model类型。

谢谢!

1 个答案:

答案 0 :(得分:0)

这应该是response.records?

$http.get("folders_list.php").success(function (response) {$scope.folder = response.records;}); 

而不是

$http.get("folders_list.php").success(function (response) {$scope.folder = response.folders;});