在Angularjs应用程序中,如果用户在超链接上持有click
然后windows
我试图在新窗口中打开,否则它应该在同一个窗口中打开。
我已经编写了代码,但它仅适用于MAC
计算机,而不适用于vm.goToDetails = function ($event) {
if ($event.ctrlKey || $event.keyCode == 91 || $event.keyCode == 224){
$window.open('/entry/' + vm.config.id + '/', '_blank');
} else {
$state.go('entry-details', { entryId: vm.config.id, query: vm.query });
}
}
即safari / chrome。
以下是JS代码
<a class="title" ng-click="$ctrl.goToDetails($event)" data-ng-bind="$ctrl.config.entryTitle"></a>
HTML CODE
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fs) {
console.log('file system open: ' + fs.name);
fs.root.getFile("newPersistentFile.txt", { create: true, exclusive: false }, function (fileEntry) {
console.log("fileEntry is file?" + fileEntry.isFile.toString());
// fileEntry.name == 'someFile.txt'
// fileEntry.fullPath == '/someFile.txt'
writeFile(fileEntry, null);
}, onErrorCreateFile);
}, onErrorLoadFs);
function writeFile(fileEntry, dataObj) {
// Create a FileWriter object for our FileEntry (log.txt).
fileEntry.createWriter(function (fileWriter) {
fileWriter.onwriteend = function() {
console.log("Successful file write...");
readFile(fileEntry);
};
fileWriter.onerror = function (e) {
console.log("Failed file write: " + e.toString());
};
// If data object is not passed in,
// create a new Blob instead.
if (!dataObj) {
dataObj = new Blob(['some file data'], { type: 'text/plain' });
}
fileWriter.write(dataObj);
});
}
答案 0 :(得分:0)
您可以像这样
尝试使用 metakeyif ($event.metaKey || $event.ctrlKey || $event.keyCode == 91 || $event.keyCode == 224) {
$window.open('/entry/' + vm.config.id + '/', '_blank');
} else {
$state.go('entry-details', { entryId: vm.config.id, query: vm.query });
}