【问题标题】:Why is ng-repeat being commented in devtools?为什么 ng-repeat 在 devtools 中被评论?
【发布时间】:2021-05-18 10:00:08
【问题描述】:

当我尝试填充选项时,没有显示任何内容。在 devtools 中,ng-repeat 似乎被注释掉了。见这里:

选项标签未被识别。我已经测试了我的 api,它们正在工作。这是我的 HTML:

     <body ng-controller="CarController as carCtrl">
        <nav>
            <ul>
                <li>Welcome ....</li>
                <li><a href="index.html">Log Out</href></a></li>
                <li><a href="ownerHome.html">Home</href></a></li>

            </ul>
        </nav>
        
            <div class="innerContainer">

      <label> Search
   <input type="text" list="dataList">
      </label>
             <datalist id="dataList">
        <option ng-repeat="type in carCtrl.types" value="{{type}}"> Type {{type}}</option>
      </datalist>

            </div>

        <footer>
            <a href="#" class="fa fa-facebook"></a>
            <a href="#" class="fa fa-instagram"></a>
            <a href="#" class="fa fa-envelope"></a>

        </footer>

    </body> 

这是我的 angularjs:

module.controller('CarController', function (registerCarAPI, $window, $sessionStorage, carAPI, carOwnerAPI, carTypeAPI, $scope) {
    this.listMessage = "Please register your car here:";
    this.types = carTypeAPI.query();
    this.cars = carAPI.query();


    this.ownerCars = carOwnerAPI.query({'ownerId': $sessionStorage.owner.OwnerID});


    this.registerCar = function (car) {


        car.ownerId = $sessionStorage.owner.OwnerID;
        registerCarAPI.save(null, car,
                function () {
                    $window.location = 'viewCars.html';
                },
                function (error) {
                    console.log(error);
                }

        );
    };


}); 

【问题讨论】:

  • 你能分享你的渲染输出吗?只需 datalist 元素、周围的 angular cmets 及其内容就足够了。
  • 我在帖子开头添加了一张照片。这够了吗?
  • Angular 这样做的唯一原因是 carCtrl.types 为空或不存在。你确定这是一组有效的数据吗?如果是这样,你能发布它的样子吗?

标签: javascript html angularjs


【解决方案1】:

您将它用作可能导致问题的选择对象。尝试将您的 datalist html 更改为:

<datalist id="dataList">
  <option ng-repeat="type in carCtrl.types" value="{{type}}"> 
</datalist>

【讨论】:

  • 感谢您的回复。不幸的是,这不是问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-10
  • 1970-01-01
  • 1970-01-01
  • 2021-01-06
  • 2021-04-23
  • 2023-03-26
  • 2018-02-08
相关资源
最近更新 更多