javascript - Nothing shows up when replace is set as true in my Angular directive -
i learning angularjs. wrote simple directive. works when replace set false. funny thing is supposed true if understand correctly. can find code @ https://jsfiddle.net/f52y5/86/.
html:
<div ng-app="bugtrackerapp" ng-controller="bugtrackercontroller"><bug-tracker title='abcde' bugs='bugs'></bug-tracker></div> script:
angular.module('bugtrackerapp', ['ui.bootstrap']) .controller('bugtrackercontroller', ['$scope', function ($scope) { $scope.bugs = [ { severity: 'high', id: '10000', summary: 'summary 1' }, { severity: 'med', id: '20000', summary: 'summary 2' }, { severity: 'low', id: '30000', summary: 'summary 3' }, { severity: 'low', id: '40000', summary: 'summary 4' }, { severity: 'low', id: '50000', summary: 'summary 5' }, { severity: 'low', id: '50000', summary: 'summary 6' }, { severity: 'low', id: '50000', summary: 'summary 7' }, { severity: 'low', id: '50000', summary: 'summary 8' }, ]; }]) .directive('bugtracker', function () { return { restrict: 'e', scope: { title: '@', bugs: '=' }, template: "<accordion><accordion-group is-open='true'>" + " <accordion-heading>{{formattitle()}}</accordion-heading>" + " <table class='bug-review'><tbody ng-repeat='bug in bugs'><tr ng-class=gettrclass(bug.severity)><td>{{bug.id}}</td><td>{{bug.summary}}</td></tr></table>" + "</accordion-group></accordion>", controller: ["$scope", function ($scope) { $scope.formattitle = function () { return $scope.title + ' (count=' + $scope.bugs.length + ')'; } }], replace: false, transclude: false };}); please note replace flag set true content shows up.
Comments
Post a Comment