Created
May 7, 2016 14:00
-
-
Save tamebadger/e56dabbaf9bd3482e61d6b62c668a8d7 to your computer and use it in GitHub Desktop.
Access Attr
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
import Ember from 'ember' | |
import TypeChecker from '../mixins/type-checker' | |
export default Ember.Controller.extend(TypeChecker, { | |
prop: 'controller property' | |
}) |
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
import Ember from 'ember' | |
const { computed } = Ember | |
export default Ember.Mixin.create({ | |
isRoute: computed('target',function(){ | |
const isUndefined = typeof this.get('target') === 'undefined' | |
return isUndefined ? true : false | |
}), | |
isController: computed('target',function(){ | |
const isUndefined = typeof this.get('target') === 'undefined' | |
return isUndefined ? false : true | |
}), | |
getAttribute(attr){ | |
let attrYouWant | |
if(this.get('isController')){ | |
attrYouWant = this.get(attr) | |
}else{ | |
attrYouWant = this.controllerFor(this.routeName).get(attr) | |
} | |
return attrYouWant | |
} | |
}) |
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
import Ember from 'ember' | |
import TypeChecker from '../mixins/type-checker' | |
export default Ember.Route.extend(TypeChecker, { | |
actions: { | |
test(){ | |
const testProp = this.getAttribute('prop') | |
console.log(testProp) | |
} | |
} | |
}) |
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
{ | |
"version": "0.8.0", | |
"EmberENV": { | |
"LOG_VERSION": false, | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.5.1", | |
"ember-data": "2.5.2", | |
"ember-template-compiler": "2.5.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment