I love angularjs, but I get so confused with directives lol.
I have the following:
//postcode grabber
app.directive('postcodes',
function ($rootScope, $http) {
return function (scope, element, attrs) {
element.bind('change', function () {
var targetSuburb = scope.$eval(attrs.targetSuburb);
alert(targetSuburb);
var modal_element = angular.element('#myModal');
var ctrl = modal_element.controller();
var url = '/postage/postcodes/?suburb=' + element.val();
ctrl.setModal(url);
modal_element.modal('show');
});
};
});
This my HTML:
<input type="text" class='form-control' ng-model="model.suburb" postcodes id='ca_suburb' target-suburb='ca_suburb' target-state='ca_state' target-postcode='ca_postcode'>
The alert is always "undefined" - Is there something I'm missing to be able to access the attributes correctly?