Aurelia select doesn't work

♀尐吖头ヾ 提交于 2020-01-11 12:29:09

问题


I have the following problem. I'm trying to fill a simple select by reading a json file and than displaying the title of any object as an option inside the select. The code works just fine when i try to display the titles inside div elements, but not as select. Here is my code:

import {inject} from 'aurelia-framework';
import {HttpClient} from 'aurelia-http-client';

@inject(HttpClient)
export class Select{
title = "Title";
images = [];
url = 'http://api.flickr.com/services/feeds/photos_public.gne?tags=rainier&tagmode=any&format=json';
favImage = '';

constructor(http) {
    this.http = http;
}

activate() {
    return this.http.jsonp(this.url).then(response => {
        this.images = response.content.items;
    });

}

}

and HTML

<template>
<div>${title}</div> 
<div repeat.for="pic of images">${pic.title}</div> //This works just fine
<select value.bind="favImage"> //This doesn't work
    <option>Select Picture</option>
    <option repeat.for="pic of images" model.bind="pic">${pic.title}</option>
</select>


回答1:


Try installing latest skelly https://github.com/aurelia/skeleton-navigation/releases which is 0.13.0. Write same code and it should work.

Make sure that the name of the model (viewmodel) which you export from your js file matches the name of the template (html) file.



来源:https://stackoverflow.com/questions/29970795/aurelia-select-doesnt-work

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!