ビューモデルからJsコントローラに関数を渡そうとしています。私のモデルビューをエクスポートしようとしました。ビューでは、ビューをキャプチャしようとしましたmodel.Nutこのエラーが表示されます:Brand.Catagory Is not a function。私のコードは次のようになります。Nativescript Module.export/Functionが機能しない
Brand_view_model:
function BrandViewModel(items) {
function Catagory (brand){
var viewmodel = new Observable({
brand: brand,
});
return viewmodel
};
}
module.exports = BrandViewModel;
Jsのコントローラー:
var BrandViewModel = require("../../shared/brand_view_model");
var Brand = new BrandViewModel([]);
exports.brand=function (args) {
var item = args.object;
var text = item.text;
Brand.Catagory(text);
frameModule.topmost().navigate("view/brand/brand");
}
ビュー:
<Page loaded="loaded">
<GridLayout>
<ListView items="{{ categoryList }}" >
<ListView.itemTemplate>
<Label text="{{ category }}" horizontalAlignment="left" verticalAlignment="center" tap="brand" />
</ListView.itemTemplate>
</ListView>
</GridLayout>
</Page>