Last active
December 19, 2015 09:38
-
-
Save mastoj/5933960 to your computer and use it in GitHub Desktop.
Issue 2031 of emberjs
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
App = Ember.Application.create(); | |
App.Router.map(function() { | |
// put your routes here | |
}); | |
App.IndexRoute = Ember.Route.extend({ | |
model: function(){ | |
return App.IndexModel.create(); | |
} | |
}); | |
var resultData = [{"Id":8,"Navn":"KPMG AS","IdNummer":"935174627","SearchResultType":1,"Historikk":[{"TidligereNavn":"KPMG AS"}],"AktiveKonsesjoner":[{"Navn":"Revisjonsselskap"}],"InAktiveKonsesjoner":[],"NummerserieNummer":["Nei",""],"ErAktiv":true,"HarHistorikk":true},{"Id":10268,"Navn":"KPMG ACCOUNTING AS","IdNummer":"997471237","SearchResultType":1,"Historikk":[],"AktiveKonsesjoner":[{"Navn":"Regnskapsførerselskap"}],"InAktiveKonsesjoner":[],"NummerserieNummer":[""],"ErAktiv":true,"HarHistorikk":false},{"Id":10326,"Navn":"KPMG TAX AS","IdNummer":"966429526","SearchResultType":1,"Historikk":[],"AktiveKonsesjoner":[{"Navn":"Regnskapsførerselskap"}],"InAktiveKonsesjoner":[],"NummerserieNummer":[""],"ErAktiv":true,"HarHistorikk":false},{"Id":10598,"Navn":"KPMG AS HOVEDKONTOR","IdNummer":"974290987","SearchResultType":2,"Historikk":[],"AktiveKonsesjoner":[],"InAktiveKonsesjoner":[],"NummerserieNummer":null,"ErAktiv":true,"HarHistorikk":false},{"Id":6716,"Navn":"KPMG AS","IdNummer":"929234359","SearchResultType":1,"Historikk":[],"AktiveKonsesjoner":[],"InAktiveKonsesjoner":[],"NummerserieNummer":null,"ErAktiv":true,"HarHistorikk":false},{"Id":2722,"Navn":"KPMG AS","IdNummer":"974279223","SearchResultType":1,"Historikk":[{"TidligereNavn":"INTER REVISJON STRAUME AS"},{"TidligereNavn":"KPMG AS"}],"AktiveKonsesjoner":[],"InAktiveKonsesjoner":[{"Navn":"Revisjonsselskap"}],"NummerserieNummer":[""],"ErAktiv":true,"HarHistorikk":true},{"Id":10599,"Navn":"KPMG AS AVD HAMAR","IdNummer":"877356752","SearchResultType":2,"Historikk":[],"AktiveKonsesjoner":[],"InAktiveKonsesjoner":[],"NummerserieNummer":null,"ErAktiv":true,"HarHistorikk":false},{"Id":10600,"Navn":"KPMG AS AVD TØNSBERG","IdNummer":"974290995","SearchResultType":2,"Historikk":[],"AktiveKonsesjoner":[],"InAktiveKonsesjoner":[],"NummerserieNummer":null,"ErAktiv":true,"HarHistorikk":false},{"Id":10601,"Navn":"KPMG AS AVD SANDEFJORD","IdNummer":"973088416","SearchResultType":2,"Historikk":[],"AktiveKonsesjoner":[],"InAktiveKonsesjoner":[],"NummerserieNummer":null,"ErAktiv":true,"HarHistorikk":false},{"Id":10602,"Navn":"KPMG AS AVD LARVIK","IdNummer":"990183597","SearchResultType":2,"Historikk":[],"AktiveKonsesjoner":[],"InAktiveKonsesjoner":[],"NummerserieNummer":null,"ErAktiv":true,"HarHistorikk":false}]; | |
App.IndexModel = Ember.Object.extend({ | |
phrase: '', | |
results: Ember.A([]), | |
changedObserver: function () { | |
this.doSearch(); | |
}.observes('phrase'), | |
init: function() { | |
this.doSearch(); | |
}, | |
doSearch: function() { | |
var modelData = resultData.map(function(item) { | |
return App.ResultatRad.create(item); | |
}); | |
this.results.setObjects(modelData); | |
} | |
}); | |
App.ResultatRad = Ember.Object.extend({ | |
erPerson: function() { | |
return this.SearchResultType === 1; | |
}.observes('SearchResultType') | |
}); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Ember Starter Kit</title> | |
<link rel="stylesheet" href="css/normalize.css"> | |
<link rel="stylesheet" href="css/style.css"> | |
</head> | |
<body> | |
<script type="text/x-handlebars"> | |
<h2>Welcome to Ember.js</h2> | |
{{outlet}} | |
</script> | |
<script type="text/x-handlebars" data-template-name="index"> | |
{{view Ember.TextField valueBinding="phrase" }} | |
<ul> | |
{{#each result in results}} | |
<li> | |
{{#if result.erPerson}} | |
person | |
{{else}} | |
foretak | |
{{/if}} | |
{{result.Navn}} | |
{{#if result.HarHistorikk}} | |
historikk | |
{{/if}} | |
</li> | |
{{/each}} | |
</ul> | |
</script> | |
<script src="js/libs/jquery-1.9.1.js"></script> | |
<script src="js/libs/handlebars-1.0.0-rc.4.js"></script> | |
<script src="js/libs/ember-1.0.0-rc.6.js"></script> | |
<script src="js/app.js"></script> | |
</body> | |
</html | |
s> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment