我想创建一个名为darkroomjs的图像插件的实例,我不确定使用什么是正确的指令。
似乎ng-bind不是正确的指令。
<div ng-repeat="(key, contents_extended_data) in moderation.contents">
<img src="" id='target_photo_[[contents_extended_data.reference]]' ng-bind="setDarkroom([[contents_extended_data.reference]])">
</div>
$scope.setDarkroom = function (reference) {
new Darkroom('#target_photo_' + reference, {
// Size options
minWidth: 100,
minHeight: 100,
maxWidth: 350,
maxHeight: 400,
ratio: 4/3,
backgroundColor: '#F0F8FF',
// Plugins options
plugins: {
save: false,
crop: {
quickCropKey: 67, //key "c"
//minHeight: 50,
//minWidth: 50,
//ratio: 4/3
}
},
// Post initialize script
initialize: function() {
var cropPlugin = this.plugins.crop;
cropPlugin.requireFocus();
}
});
};
提前致谢!
答案 0 :(得分:2)
我会制作自己的指令
我没有任何方便,但试试这个:
<img darkroom src="" id='target_photo_[[contents_extended_data.reference]]'>
img标签中的:
return {
restrict: 'A',
scope: {darkroom: '='},
link: function(scope, elem, attrs) {
new Darkroom(id, scope.darkroom)
}...
要为每个img传递不同的选项,请使用指令范围:
<img darkroom="options" src="" id='target_photo_[[contents_extended_data.reference]]'>
然后你在这里传递选项:
$scope.options = {
// Size options
minWidth: 100,
minHeight: 100,
maxWidth: 350,
maxHeight: 400,
ratio: 4/3,
backgroundColor: '#F0F8FF',
// Plugins options
plugins: {
save: false,
crop: {
quickCropKey: 67, //key "c"
//minHeight: 50,
//minWidth: 50,
//ratio: 4/3
}
},
// Post initialize script
initialize: function() {
var cropPlugin = this.plugins.crop;
cropPlugin.requireFocus();
}
}
在控制器中:
<select name='category[123]'>
<option value='0'>off</option>
<option value='1'>on</option>
</select>
<select name='category[456]'>
<option value='0'>off</option>
<option value='1'>on</option>
</select>
<select name='anothercategory[123]'>
<option value='0'>off</option>
<option value='1'>on</option>
</select>
<select name='anothercategory[456]'>
<option value='0'>off</option>
<option value='1'>on</option>
</select>