I am trying to bind the temperature property of my controller to the temp property of my settings object. I am attempting this in an ember generated controller file app/controllers/home.js
var settings = Ember.Object.create({
temp: 66
});
export default Ember.Controller.extend({
temperatureBinding: "settings.temp"
});
While trying different possible solutions I discovered that this code snippet works when I create my settings object like so:
App = Ember.Application.create();
App.settings = Ember.Object.create({
temp: 65
})
App.Controller = Ember.Controller.extend({
temperatureBinding: 'App.settings.temp',
})
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Ember Starter Kit</title>
<link rel="stylesheet" href="http://ift.tt/1x2iORp">
<script src="http://ift.tt/1mWWrGH"></script>
<script src="http://ift.tt/1VfQY14"></script>
<script src="http://ift.tt/1gYfl0n"></script>
</head>
<body>
<script type="text/x-handlebars">
Temperature:
</script>
</body>
</html>
Unfortunately when I attempt this in my home.js file it throws an error because App is not defined in that file. Is this way of doing data binding even possible with Ember? If so, what I am doing wrong?
Aucun commentaire:
Enregistrer un commentaire