Angularjs ng重复中的角度更新ng模型
基本上,我正在试图找到一种方法,将一个选定的值(比如,从一个模式)返回到一个特定的模型,而该模型可以通过ng repeat动态生成 这就是我的数据的样子:Angularjs ng重复中的角度更新ng模型,angularjs,Angularjs,基本上,我正在试图找到一种方法,将一个选定的值(比如,从一个模式)返回到一个特定的模型,而该模型可以通过ng repeat动态生成 这就是我的数据的样子: { "title": "Example Title", "enabled": true, "thumbnailImage": "file1.png", "content": [{ "order": 0, "type": "wysiwyg", "content":
{
"title": "Example Title",
"enabled": true,
"thumbnailImage": "file1.png",
"content": [{
"order": 0,
"type": "wysiwyg",
"content": "<div>This is wysiwyg content!</div>"
},
{
"order": 1,
"type": "image",
"content": "file2.png"
}],
"id": 1
}
然后,每个图像下“选择图像”按钮旁边的“插入图像”按钮将更新模型。但是,我希望能够在模式中做到这一点,因此用户所要做的就是单击“关闭”模式按钮,然后填充字段
这有意义吗?有可能吗?我获取ng repeat的特定项的方法是将其传递给视图中的函数
<html element ... useSelectedFile(file)></html element>
modal是否已经可以显示图像了?它有自己的控制器吗?有。我想我只是把自己弄糊涂了,让事情变得比必要的更难——Jinw下面的解决方案非常有效。Doh,我想得太多了。是的,很好用。谢谢你,金惠,欢迎你!我的代码也太复杂了,这很容易做到。
<div ng-if="showFileManager" nv-file-drop uploader="uploader">
<div class="row">
<div ng-repeat="file in files" class="col-3">
<img ng-src="/{{ file.container }}/{{ file.name }}" ng-click="setActiveImage( file )">
</div>
</div>
<div ng-show="uploader.isHTML5">
<div nv-file-over uploader="uploader">
Drag and drop images to upload
</div>
</div>
</div>
$scope.setActiveImage = function( file ) {
var filePath = 'http://localhost:3000/uploads/' + file.container + '/' + file.name;
$scope.activeImage = filePath;
};
<html element ... useSelectedFile(file)></html element>
$scope.useSelectedFile = useSelectedFile;
function useSelectedFile(file){
//do stuff
//call function
//set scope item in view to file
}