Home > front end >  $scope. $under the watch of nested for loop inside the if no effect
$scope. $under the watch of nested for loop inside the if no effect

Time:09-21

How to achieve fuzzy search keyword search will be displayed after the content of the keyword, and shows its content, the title,



<meta charset="UTF-8">
<meta name="viewport"
The content="width=device - width, user - scalable=no, initial - scale=1.0, the maximum - scale=1.0, minimum - scale=1.0" & gt;
<meta HTTP - equiv="X - UA - Compatible" content="ie=edge" & gt;
<meta name="keywords" content="" & gt;
<meta name="viewport" content="width=device - width, initial - scale=1.0" & gt;
Homework three & lt;/title> <br/><link rel="stylesheet" href="https://bbs.csdn.net/css/bootstrap.css" & gt; <br/><script SRC="https://bbs.csdn.net/js/angular.js" & gt; </script> <br/><script SRC="https://bbs.csdn.net/js/angular-sanitize.min.js" & gt; </script> <br/></head> <br/><body ng - controller="CTR & gt;" <br/><Input type="text" ng - model="Newsname. The name" & gt; <br/><Ul & gt; <br/><Li ng - repeat="item in the newsList" & gt; {{item. Cn}} & lt;/li> <br/></ul> <br/><Ul & gt; <br/><Li ng - repeat="item in newsData [activeitem] | filter: Newsname. The name" & gt; <br/><Div & gt; <br/><Div & gt; <br/>{{item. The title}} <br/></div> <br/><Div & gt; <br/><Img ng - SRC="https://bbs.csdn.net/topics/{{item. PicInfo [0]. Url}}" style="width: 100 px" & gt; <br/></div> <br/><br/></div> <br/><br/></li> <br/></ul> <br/><br/></body> <br/></html> <br/><script> <br/>Presents the module (" app ", [" ngSanitize "]) <br/>Controller (" CTR, "[" $scope", "$HTTP", "$rootScope", the function ($scope, $HTTP, $rootScope) {<br/>$rootScope. NewsList=[<br/>Cn: {en: "auto", "car", the state: true}, <br/>Cn: {en: "dy", "recommended", the state: true}, <br/>Cn: {en: "ent", "entertainment", the state: true}, <br/>Cn: {en: "home", "home", the state: true}, <br/>Cn: {en: "sports", "sports", the state: true}, <br/>Cn: {en: "tech", "science and education", the state: true}, <br/>Cn: {en: "toutiao," "news," the state: true}, <br/>Cn: {en: "war", "military", the state: true}, <br/>Cn: {en: "money", "financial", the state: false} <br/>]; <br/>$rootScope. Activeitem="toutiao"; <br/>$scope. Newsname={" name ":" "}; <br/>Var url="yaowen. Json"; <br/>$scope. The getNews=function () {<br/>HTTP (${<br/>Methon: "GET", <br/>Url: the url <br/>{}). Then (function (res) <br/>$rootScope.newsData=https://bbs.csdn.net/topics/res.data.data; <br/><br/>}), <br/>Function (err) {<br/>} <br/>}; <br/><br/>$scope. $watch (" Newsname ", function (n, o) {<br/>For (var index in $rootScope. NewsData) {<br/>for(var i=0; i<$rootScope. NewsData [index]. Length; I++) {<br/>If (n.n ame==$rootScope. NewsData [index] [I] title) {<br/>$scope. Newscn=$rootScope. NewsData [index] [I] the category; <br/><br/><br/>} <br/>} <br/>The console. The log ($rootScope. NewsData [index] [I] the category) <br/>} <br/><br/>}); <br/>$scope. The getNews (); <br/><br/><br/>}]) <br/></script> </div> <div class="th_page th_page_color"></div> <div class="umCopyright"> <p>Page link:<a href="/frontend/16861.html" target="_blank" style="color:#999">https//www.codepudding.com/frontend/16861.html</a></p> </div> <div class="detail-arr"> <div class="detail-arr-left">Prev:<a href='/frontend/16860.html'>I want to implement a search content, then automatically match the title of the relevant content and</a></div> <div class="detail-arr-right">Next:<a href='/frontend/16862.html'>Want to copy the data from the file to the two dimensional array but print the result out of the que</a></div> </div> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="hot-tags neitags"> <ul> <li><i class="iconfont icon-x-tags"></i> Tags:  </li> <a href='/e/tags/?tagname=JavaScript' target='_blank'>JavaScript</a> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="xiangguan"> <ul class="msg msghead"> <li class="tbname">Related</li> </ul> <ul> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="flinks"> <ul> <li><i class="iconfont icon-x-tags"></i> Links:  </li> <li class="liflinks"><a target="_blank" href="/" title="CodePudding">CodePudding</a></li> </ul> </div> </div> </div> </div> <div class="footer"> <p><span style="font-size:16px;color:#666;font-weight: bold">About Us:</span>  <a href="https://www.codepudding.com/contact.html">Contact Us</a>      <a href="https://www.codepudding.com/service.html">Terms of Service</a>      <a href="https://www.codepudding.com/privacy.html"> Privacy Policy</a></p> <p class="foot_info">Copyright © 2010-2023,Powered By <a href="/" target="_blank">CodePudding</a> </p> </div> <script type="text/javascript" src="/skin/code/tianhu.js"></script> </body></html>