AngularJS Error: element is undefined (caused by "undefined") -
i have directive create dropdown dynamically, when renders on page, in firefox , ie 11 below exceptions:
firefox exceptiton:
"error: element undefined (caused "undefined") getaliasedattrname@http://localhost:63342/inventory-client/bower_components/angular/angular.js:3056:7 $compileprovider/this.$get</attributes.prototype.$set@http://localhost:63342/inventory-client/bower_components/angular/angular.js:7179:26 interpolatefnwatchaction@http://localhost:63342/inventory-client/bower_components/angular/angular.js:8547:23 interpolatefnwatcher@http://localhost:63342/inventory-client/bower_components/angular/angular.js:10874:17 watchgroupaction@http://localhost:63342/inventory-client/bower_components/angular/angular.js:15355:13 $rootscopeprovider/this.$get</scope.prototype.$digest@http://localhost:63342/inventory-client/bower_components/angular/angular.js:15683:23 $rootscopeprovider/this.$get</scope.prototype.$apply@http://localhost:63342/inventory-client/bower_components/angular/angular.js:15951:13 ngeventhandler/<@http://localhost:63342/inventory-client/bower_components/angular/angular.js:23303:17 jquery.event.dispatch@http://localhost:63342/inventory-client/bower_components/jquery/dist/jquery.js:4434:15 jquery.event.add/elemdata.handle@http://localhost:63342/inventory-client/bower_components/jquery/dist/jquery.js:4121:6 invoke@http://localhost:63342/inventory-client/bower_components/webcomponentsjs/webcomponents.js:1090:55 dispatchattarget@http://localhost:63342/inventory-client/bower_components/webcomponentsjs/webcomponents.js:1039:14 dispatchevent@http://localhost:63342/inventory-client/bower_components/webcomponentsjs/webcomponents.js:1017:13 dispatchoriginalevent@http://localhost:63342/inventory-client/bower_components/webcomponentsjs/webcomponents.js:973:1 " undefined
ie 11 exception:
typeerror: unable property 'nodename' of undefined or null reference (caused "undefined") @ getaliasedattrname (http://localhost:63342/inventory-client/bower_components/angular/angular.js:3056:3) @ attributes.prototype.$set (http://localhost:63342/inventory-client/bower_components/angular/angular.js:7179:13) @ interpolatefnwatchaction (http://localhost:63342/inventory-client/bower_components/angular/angular.js:8547:23) @ interpolatefnwatcher (http://localhost:63342/inventory-client/bower_components/angular/angular.js:10874:17) @ watchgroupaction (http://localhost:63342/inventory-client/bower_components/angular/angular.js:15355:13) @ scope.prototype.$digest (http://localhost:63342/inventory-client/bower_components/angular/angular.js:15683:23) @ scope.prototype.$apply (http://localhost:63342/inventory-client/bower_components/angular/angular.js:15951:13) @ anonymous function (http://localhost:63342/inventory-client/bower_components/angular/angular.js:23303:17) @ jque
below angualrjs directive code along html:
module.directive('bootstrapdropdown', ['$compile', '$timeout', function ($compile, $timeout) { return { restrict: 'e', require: '^ngmodel', scope: { ngmodel: '=', items: '=', callback: '&', placeholder: '@' }, link: function (scope, element) { scope.$evalasync(function (scope) { scope.selectval = function (item) { scope.ngmodel = item; $('button.dropdown-toggle', element).html(item.name + ' <span class="caret"></span>'); if (scope.callback) { scope.callback({item: item}); } }; var html = ''; html += '<div class="form-item dropdown">'; html += ' <button class="dropdown-select dropdown-toggle" type="button" data-toggle="dropdown" >'; html += ' {{placeholder}}<span class="caret"></span>'; html += ' </button>'; html += ' <ul class="dropdown-menu" role="menu">'; html += ' <li role="presentation" data-ng-repeat="item in items"><a data-ng-href="" role="menuitem" tabindex="-1" data-ng-click="selectval(item)">{{item.name}}</a></li>'; html += ' </ul>'; html += '</div>'; element.append($compile(html)(scope)); }); } }; }]);
html:
<bootstrap-dropdown id="dropdowncondition{{$index}}" ng-model="inventory.condition" items="getgroups('conditions', $index)" ng-init="inventory.condition.name='and'" placeholder="and"> </bootstrap-dropdown>
Comments
Post a Comment