0

I need to embed a small HTML snippet in a column of a Yii2 GridView. The HTML contains angular directives (i.e., ng-repeat). Here is the GridView column:

                [
                    'label' => 'Column',
                    'format' => 'html',
                    'value' => function ($model) {
                        $return = '';
                        $return.= '<div ng-repeat="el in elements">';
                        $return.= '<h4>El Title: {{el.title}}</h4>';
                        $return.= '</div>';

                        return $return;
                    }
                ],

The GridView is inside an angular controller that should compile it when the page is rendered. However, the ng-repeat loops is ignored, while the {{el-title}} expression is evaluated empty (which tells me that angular compiled {{el.title}} but could not deal with the ng-repeat. Any suggestion?

gcswoosh
  • 1,279
  • 1
  • 15
  • 31
  • Show code of `ng-controller` please – Leguest Apr 30 '17 at 17:33
  • Well the ng-controller does not do any special operation. I just wrapped the grid inside the controller then I guess it should compile the yii2 grid by itself when the page is rendered, like with standard html, am I wrong? – gcswoosh May 01 '17 at 10:13
  • I suppose you should have `$scope.elements` with data somewhere in your ng-controller – Leguest May 01 '17 at 11:15
  • Yes, actually '$scope.elements' is built dynamically by another section of the same page. This is done after the grid is rendered. – gcswoosh May 01 '17 at 12:03
  • I believe you need `$scope.elements` should be accessible before grid is rendered – Leguest May 01 '17 at 12:19

0 Answers0