Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function makeProduct(toConvert) {
- var product = {
- description:'',
- // ...
- rules: makeRules({
- onFoo(){ product.x = y; }
- })
- };
- angular.extend(product, toConvert);
- return product;
- }
- function makeRules(opts){
- return {
- onChange: function() {
- console.log("Applying global change rules: ", this);
- opts.onFoo();
- },
- onInstantiation: function() {
- console.log("Applying instantiation rules: ", this);
- },
- onContextApplication: function(room) {
- this.context = room;
- console.log("Applying context rules: ", this, room);
- },
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement