【问题标题】:How can izitoast ng-repeat in agularjs如何在 angularjs 中进行 izitoast ng-repeat
【发布时间】:2021-10-08 17:08:19
【问题描述】:
<tr ng-repeat="item in self.quantitativeEvaluationQuestions">
            <th>{{ item.key }}</th>
            <td ng-bind="self.completeInfo[item.value] | quantitativeEvaluationOptionsFilterVc"></td>
          </tr>

如何在 izitoast 中使用 angularjs 在数组中重复

【问题讨论】:

    标签: javascript angularjs angularjs-ng-repeat


    【解决方案1】:

    izitoast 的这个问题不理解 angularjs。
    为了解决这个问题,angularjs 给了我们 $compile()。

              self.quantitativeEvaluationQuestions = [
                {
                  key:'foo',  
                  value:'bar'
                },
              ];
              
              const rawHtml = 
                `
                <tr ng-repeat="item in self.quantitativeEvaluationQuestions">
                    <th>{{ item.key }}</th>
                    <td ng-bind="self.completeInfo[item.value] | quantitativeEvaluationOptionsFilterVc"></td>
                 </tr>
                `;
             
                const compiledHtml = $compile(rawHtml)($scope);
    

    与 $timeout 一起使用:

                $timeout(() => {
                  iziToast.show({
                    inputs: [
                      [compiledHtml[0].outerHTML, function (instance, toast) {}]
                    ],
                  });
                });     
    

    或与 $apply 一起使用:

          $scope.$apply()
          iziToast.show({
             inputs: [
               [compiledHtml[0].outerHTML, function (instance, toast) {}]
             ],
          });  
    

    【讨论】:

    • 这个灵魂有效,谢谢。但我希望 iziToast 可以呈现 angualrjs 而不是像字符串一样的行为。
    猜你喜欢
    • 1970-01-01
    • 2017-03-17
    • 2017-12-22
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多