如何在angularJS中的ng repeat中绑定字符串值
这是我的密码如何在angularJS中的ng repeat中绑定字符串值,angularjs,angularjs-ng-repeat,Angularjs,Angularjs Ng Repeat,这是我的密码 $scope.records = "test,Test1,Test2,test3,test4"; 我想在li标记中用ng-repeat绑定这个值。需要像这样输出吗 .test .Test1 .Test2 .Test3 .Test4 您可以使用运算符拆分上的字符串,然后可以使用ng repeat 模块'myApp',[]; 角度。模块'myApp'。控制器'MyController',MyController; 函数MyController$scope{ $scope.re
$scope.records = "test,Test1,Test2,test3,test4";
我想在li标记中用ng-repeat绑定这个值。需要像这样输出吗
.test
.Test1
.Test2
.Test3
.Test4
您可以使用运算符拆分上的字符串,然后可以使用ng repeat
模块'myApp',[];
角度。模块'myApp'。控制器'MyController',MyController;
函数MyController$scope{
$scope.records=test、Test1、Test2、test3、test4;
$scope.records=$scope.records.split',';
};
{{record}}
请检查工作plnkr以了解您的要求 使用 var app=angular.moduleapp,[]; app.controllerctrl,功能$scope{ $scope.records=[test,Test1,Test2,test3,test4]; }; 使用自定义过滤器 模块'myApp',[]; var app=角度。模块“myApp” 应用控制器'MyController',MyController; 应用程序。过滤器“拆分”,函数{ 返回函数输入,位置{ 变量拼接位置=拼接位置| |','; 返回input.splitplace; } }; 函数MyController$scope{ $scope.records=test、Test1、Test2、test3、test4; }; -> {{record}} 查找您的Ans:
<body>
<div ng-app="App" ng-controller="mycontroller">
{{records}} <br/>
{{arrays}}<br />
<ul>
<li ng-repeat="array in arrays"> {{array}}</li>
</ul>
</div>
<script type="text/javascript">
var app = angular.module("App",[]);
app.controller("mycontroller",function($scope){
$scope.records = "test,Test1,Test2,Test3,Test4";
$scope. arrays = $scope.records.split(',');
})
</script>
首先将该字符串转换为数组,然后在li中使用ng repeat 请检查链接
[Please check the link]
使用angularJS featuresWelcome@GangadharJannu的好方法
[Please check the link]