Created
September 18, 2016 19:39
-
-
Save navarroaxel/995b3c1828371aafe73c4e2a602e8555 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ng-repeat="alert in $ctrl.alerts"> | |
<div>{{alert.message}}</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('vic.surveys').component('alert', { | |
templateUrl: '...', | |
binding: { | |
member:'<' | |
}, | |
controller: ['_',function (_) { | |
let $ctrl = this; | |
$ctrl.$onChanges = () => { | |
$ctrl.alerts = _(memberAlertService.age) | |
.map(func => func($ctrl.member)) | |
.filter(err => err) | |
.value(); | |
} | |
}] | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('vic.surveys').factory('memberAlertService', { | |
function rule1() { | |
} | |
function rule2() { | |
} | |
return { | |
age: { | |
rule1, | |
rule2 | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="number" ng-model="member.age"/> | |
<alert-member-age></alert-member-age> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment