Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.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
Html AngularJS中的过滤对象使我的字符串对象将每个字符串转换为一个字符数组_Html_Angularjs - Fatal编程技术网

Html AngularJS中的过滤对象使我的字符串对象将每个字符串转换为一个字符数组

Html AngularJS中的过滤对象使我的字符串对象将每个字符串转换为一个字符数组,html,angularjs,Html,Angularjs,我试图通过用户输入文本框来过滤数据 加载页面时,所有数据都会正确显示。 在文本框中键入文本时,所有字符串都将变为字符数组- 删除文本框中的文本后,数据如下- 这是我正在使用的代码- <!DOCTYPE html> <html ng-app="FormatsApp" ng-controller="LinksController"> <head> <title></title> <meta charset="ut

我试图通过用户输入文本框来过滤数据

加载页面时,所有数据都会正确显示。

在文本框中键入文本时,所有字符串都将变为字符数组-

删除文本框中的文本后,数据如下-

这是我正在使用的代码-

<!DOCTYPE html>
<html ng-app="FormatsApp" ng-controller="LinksController">
<head>
    <title></title>
    <meta charset="utf-8" />
</head>
<body>
    <label class="label-to-left">Search Formats: </label>
    <input type="text" name="txtSearchFormats" ng-model="txtSearchFormats" />
    <div id="formatsBox">
        <div ng-repeat="i in items">{{ i.name | filter:txtSearchFormats }}</div>
    </div>
    <!-- Angualr -->
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular.min.js"></script>
    <script>
        var formatsApp = angular.module('FormatsApp', []);
        formatsApp.controller('LinksController', function LinksController($scope) {
            $scope.items = [{ name: "Hello" }, { name: "Goodbye" }];
        });
    </script>
</body>
</html>

搜索格式:
{{i.name |过滤器:txtSearchFormats}
var formatsApp=angular.module('formatsApp',[]);
formatsApp.controller('LinksController',函数LinksController($scope){
$scope.items=[{name:“你好”},{name:“再见”}];
});

这里出了什么问题?

您的错误是,您在表达式中使用了
过滤器。因此,您需要使用with
ng repeat

使用
{i.name}


搜索格式:
{{i.name}
var formatsApp=angular.module('formatsApp',[]);
formatsApp.controller('LinksController',函数LinksController($scope){
$scope.items=[{name:“你好”},{name:“再见”}];
});

您的错误是,您在表达式中使用了
过滤器。因此,您需要使用with
ng repeat

使用
{i.name}


搜索格式:
{{i.name}
var formatsApp=angular.module('formatsApp',[]);
formatsApp.controller('LinksController',函数LinksController($scope){
$scope.items=[{name:“你好”},{name:“再见”}];
});

您的筛选器应应用于ng repeat而不是表达式

  <div ng-repeat="i in items  | filter:txtSearchFormats">{{ i.name }}</div>
  </div>

搜索格式:
{{i.name}

您的筛选器应应用于ng repeat而不是表达式

  <div ng-repeat="i in items  | filter:txtSearchFormats">{{ i.name }}</div>
  </div>

搜索格式:
{{i.name}