Search code examples
javascriptangularjsangularjs-ng-repeat

How can izitoast ng-repeat in agularjs


<tr ng-repeat="item in self.quantitativeEvaluationQuestions">
            <th>{{ item.key }}</th>
            <td ng-bind="self.completeInfo[item.value] | quantitativeEvaluationOptionsFilterVc"></td>
          </tr>

how can i repeat in array with angularjs in izitoast


Solution

  • this problem for izitoast does not understand angularjs.
    to solve this problem, angularjs gave us $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);
    

    use with $timeout:

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

    or use with $apply:

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