angularjs - Extending Chips from angular-material -
i'm trying create layer on top of md-chips
called chip-filter
which has functionality build in;e.g.
- a navigation chip (when removed, redirects user specific url)
- add place n app chip
- ...
so got basics working, hooking in componentsregistry, , being able call place.
but i'm trying chips chipfiltercontroller <md-chips>
html:
<chip-filter md-component-id="testid"> <md-chips ng-model="chips"> <md-chip-template> <strong>{{$chip}}</strong> <em>(type)</em> </md-chip-template> </md-chips> </chip-filter>
and directive:
function chipfilterdirective($log) { function postlink(scope, element, attr, sidenavctrl) { element.on("$destroy", function() { sidenavctrl.destroy(); }); } return { restrict: "e", scope: {}, controller: "chipfiltercontroller", compile: function(element) { return postlink; } }; }
and controller:
function chipfiltercontroller($scope, $element, $attrs, $mdcomponentregistry, $q, $log) { var self = this; $scope.chips = []; function addchip(input, type) { var def = $q.defer(); $scope.chips.push({ name: input, type: type }); def.resolve(); return def.promise; } self.addnavigationchip = function() { return addchip("stuff"); }; self.addchip = function() { return addchip("stuff"); }; self.destroy = $mdcomponentregistry.register(self, $attrs.mdcomponentid); }
full codepen: http://codepen.io/cskiwi/pen/ejryqk?editors=1010
setting scope
false (or removing object) made work
Comments
Post a Comment