I’ve created my own directive base on ionic directives, but I have two problems. My scope property called “vFilter” doesn’t work ( there isn’t any binding). The second problem is with creating button element in link function (devTools show me html with buttons, but I don’t see it).
Code:
angular.module('Project.UI.Elements')
.directive('listView', [function() {
return {
replace: true,
restrict: 'E',
scope: {
vTitle: '@',
vButtons: '=?',
vFilter: '=',
vRefresh: '&'
},
transclude: true,
template: '<ion-view title="{{vTitle}}">' +
'<ion-nav-buttons side="right"></ion-nav-buttons>'+
'<ion-content class="has-header">' +
'<label class="item item-input">' +
'<i class="icon ion-search placeholder-icon"></i>' +
'<input type="text" placeholder="Search" ng-model="vFilter">' +
'</label>' +
'<ion-refresher on-refresh=vRefresh() refreshing-icon="ion-ios7-reloading" pulling-icon="ion-ios7-arrow-thin-down"></ion-refresher>' +
'<ion-list ng-transclude> </ion-list>' +
'</ion-content>' +
'</ion-view>',
link: function(scope, elem, attrs) {
buttons = elem.find('ion-nav-buttons');
angular.forEach(scope.vButtons, function (buttonDef) {
button = angular.element('<button></button>');
button.attr('ui-sref', buttonDef.state);
button.addClass(buttonDef.type);
buttons.append(button);
});
}
};
}]);
vButtons attribute example:
$scope.Buttons = [{
state : "main.clientEdit",
type: "button button-icon icon ion-plus-round",
}];