从angularjs应用程序中的jQuery-contextMenu获取模型

时间:2018-09-27 12:41:59

标签: jquery angularjs contextmenu

我想在angularjs应用中使用jQuery-contextMenu

其他功能工作正常,但我想从ng-repeat列表中获取模型...

documents.html中的代码段如下所示

<p
		ng-repeat="dox in _xp.docs | orderBy: _xp.query.order | filter: filter.search | limitTo: _xp.query.limit : (_xp.query.page - 1) * _xp.query.limit"
		layout="column"
		layout-align="start center"
		ng-if="_xp.docs.length"
		class="fades md-padding superEdit">
		<p
			ng-style="{
				cursor: 'pointer',
			}">
			<md-icon 
				md-svg-icon='{{dox.icon}}'
				ng-style="{
					color: '#3ae',
					width: '64px',
					height: '64px'
				}"
				ng-click='_xp.onExplore(dox, $event)'></md-icon>
		</p>
		<p>{{dox.name}}</p>
	</p>

和我的组件document.js如下。

            // the context menu options
            $.contextMenu(
                {
                    // define which elements trigger this menu
                    selector: ".superEdit",
                    // define the elements of the menu
                    items: {
                        'all': {
                            name: "Edit", 
                            icon: "edit",
                            callback: vm.onUpdate
                        },
                        bar: {
                            name: "Delete", 
                            icon: "delete",
                            callback: vm.onPurge
                        }
                    }
                    // there's more, have a look at the demos and docs...
                }
            );

        // rename file or folder
        vm.onUpdate = function (key, opt) {                
            // restrict user if they don't have access
            $auth.accessible().forEach(element => {
                if (element.state === 'documents') {
                    if (parseInt(element.canedit) === 1) {
                       //here i want to grab the model **dox** from the documents.html, how can I do that?....
                        vm.item = opt;
                        vm.item.modifiedby = vm.user.username;

                        $mdDialog.show({
                            controller: 'renamectrl as _rn',
                            templateUrl: 'components/documents/edit/edit-dialog.html',
                            parent: angular.element(document.body),
                            targetEvent: ev,
                            clickOutsideToClose: true,
                            locals: {
                                item: vm.item
                            }
                        }).then(function(doc) {

                            doc = new $xplorer(doc);

                            // real editing document is done here
                            doc.$update(function(res) {
                                if (res.done) {                                        
                                    vm.onReload();
                                }

                                // renaming succeeded
                                $mdToast.show(
                                    $mdToast.simple()
                                    .textContent(res.msg)
                                    .position('top center')
                                    .hideDelay(1000)
                                );
                            });

                        }, function() {
                            $mdToast.show(
                                $mdToast.simple()
                                .textContent('Changes not applied')
                                .position('top center')
                                .hideDelay(1500)
                            );
                        });
                    } else {
                        // unselect the model

                        // play the error sound
                        return;
                    }
                }
            });
        } // updating file / folder ends

当我从上下文菜单中单击编辑选项时,如何将模型从documents.html捕获到vm.onUpdate函数中?

0 个答案:

没有答案