Tag: angularjs

AngularJS指令与ng-repeat – misbehavior共享范围

我遇到了一个奇怪的情况。 我需要有两个可排序的列表,它们应该通过拖放或添加/删除事件来交换元素。 我创建了一个运行良好的指令。 控制器事件也能做正确的工作。 当组合方法时,问题就开始了(按钮添加+拖放+按钮再次添加按钮)。 KA-BOOM! 我把这个plnkr放在一起: http ://plnkr.co/edit/DumufP1kDdkz1INAXwmF?p = preview 单击元素,然后单击按钮操作(添加/删除)。 让我分享一些指令的代码只是为了好玩,但请访问链接以查看整个实现。 有关如何在plnkr中重现该问题的更多信息 .directive(‘sortableList’, function ($log) { return { restrict: ‘A’, scope: { fromList: ‘=’, toList: ‘=’ }, link: function (scope, elm, attrs) { var callback = { receive: function (event, ui) { //– Get the scope of the list-item var scopeItem = ui.item.scope(); […]

突出显示angularjs中跨度的文本

目前我有一个代码,如果与此数组匹配,则突出显示列表中的单词。 $scope.arrayFilter=[“is”,”mom”,”beautifull”,’beer’]; 我不再需要这段代码。 我只需要从数组中突出显示类“.marque”的文本,而不会失去执行“选取框”效果的库的效果。 我该怎么做? https://jsfiddle.net/mafa4hro/ mom is beautifull var app = angular.module(‘testApp’,[]); app.controller(‘testCtrl’,function($scope){ $scope.arrayFilter=[“mom”,”is”,”beautifull”,’beer’]; $scope.data = [{ title: “mom is beautifull” }, { title: “my mom is great” }, { title: “I hate the matematics” }]; //marquee effect $(‘.marquee’).marquee({ duration: 5000 }); $(‘.marquee’) .bind(‘finished’, function(){ console.log(‘finish’) $(this).html(‘If it works, i need a beer’) //Apply […]

如何禁用Cordova Android中的YouTube背景播放?

当我锁定手机时,我正试图阻止YouTubevideo播放。 我尝试了SO中提供的几乎每个解决方案,但问题仍然存在。 当我的Cordova应用程序进入后台时,如何在InAppBrowser上暂停YouTubevideo? 在onPause之后,PhoneGap继续在Android上运行 如何禁用在phonegap android中播放youtube背景 如何在Android webview中停止播放YouTubevideo? 由于网络政策存在一些问题,我的应用因谷歌播放被拒绝了? 我该如何解决这个问题:app可以播放YouTubevideo 应用程序可以播放video,cordova问题,谷歌播放拒绝应用程序 我在confix.xml中添加了以下代码。 HTML和Angular代码 <!– –> 角 var ProfileApp = angular.module(‘ProfileApp’, [‘youtube-embed’]); $scope.$on(‘youtube.player.ready’, function ($event, player) { $rootScope.YTPlayer = player; }); 一些JS代码来检测暂停事件。 document.addEventListener(“pause”, function() { if ($rootScope.YTPlayer) { $rootScope.YTPlayer.stopVideo(); //or maybe $rootScope.YTPlayer.pauseVideo(); } }, false); 你可以看到我尝试了iframe和YouTube API两种方法,但都没有。 请告知我如何停止播放YouTubevideo。

使用数组反向查找对象

如果我有这样的对象,请说 resourceMap = { “a”: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], “b”: [11, 12], “c”: [21, 23], “d”: [54, 55, 56, 57, 510] }; 找出resourceId = 21是否为”c”的最佳方法是什么? 我们不知道密钥的名称或密钥数量。 它只匹配一次:意思是21只属于一个键”c” 。 我正在考虑循环遍历所有键并执行indexOf() ,但我觉得它不够“优雅”。 我可以使用Underscore但是尽量避免使用Angular或jQuery或者只是使用vanilla Javascript。

Angularjs:禁用tab键默认行为

我正在开发一个输入表。 我想要的是:当使用按‘+’键 (光标在表格行中的任何地方)时,应用程序在表格中添加一个新行。 它做得很好: 我的问题是,当用户在行的输入中按Tab键转到下一个输入时,下一个输入值将突出显示 (这是tab键的正常行为)。 然后,如果用户按“+”添加新行,它将用“+”符号替换输入值。 我已经设置了一个指令,允许用户只在输入中键入数字,但是当输入值突出显示时它不起作用。 angular.module(‘myApp’).directive(‘numbersOnly’, function($timeout) { return { require: ‘ngModel’, link: function(scope, element, attrs, modelCtrl) { modelCtrl.$parsers.push(function (inputValue) { // this next if is necessary for when using ng-required on your input. // In such cases, when a letter is typed first, this parser will be called // again, and […]

如何使用angularjs在新窗口中打开我的页面?

从我的控制器A,我正在做以下事情 – $window.open(“/signals”, “menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes”); //$location,path(“/signals”); 我的routeprovider配置如下 – .when(‘/signals’,{ templateUrl: ‘app/views/signals.html’, controller: ‘signalsCtrl’, controllerAs : ‘signals’ }) 我的signalsCtrl控制器使用的服务返回一个必须在新窗口中显示的图像列表 – signals.html: angular.module(‘myApp’).controller(‘signalsCtrl’, [‘$scope’, ‘$log’, ‘criteriaService’, function ($scope, $log, criteriaService) { var signals=this; signals.getUrls = function(){ return criteriaService.getUrls() }; }]); signals.html使用ng-repeat循环遍历列表并显示图像。 问题是当我使用$ location.path(“/ signals”)时,当我单击父页面上的按钮时,它会在同一窗口(重定向)中打开新页面时工作正常。 但是使用$ window.open它根本不起作用。 当我尝试使用$ window.open(“/ signals”)尝试访问此页面时,我看不到我的控制器(SignalsCtrl)被触发。 我怎样才能让它发挥作用? 我也考虑过使用模态,但是当用户可以在父页面上工作时,我需要让模态始终保持打开状态。 然而,模态不允许这样做。 所以我试图在新窗口中创建一个新页面,但这也不起作用。 这里的任何指针都将非常感激。 我看到当页面加载时我们正在重置会话。 由于窗口打开一个新页面,会话正在重置,并且由于它返回到主页面,因此用户可以再次选择条件。 this.login = […]

删除元素时的angularJS通知

我正在创建一个新的指令,我想知道当角度从DOM中删除元素时如何通知。 我的目标是在删除元素时添加jquery动画。

密码文本的ng-pattern接受所有特殊字符和数字,字母

HTML username 以上图案适用于以下符号 @ # $ % & ! * 但我想允许所有特殊字符 { } [ ] ( ) ^ + – = ; : ‘ ” / \ | plunkr链接 如何在该模式中包含适用于密码的所有特殊字符?

Angular中JSON数据的分页

当用户将url输入到输入中时,我从我的服务器下载数据,然后单击“提交”。 接下来,我用HTML显示这些数据: {{printResult.pg}} {{offer.name}} printResult.pg是一些页面 我想从1添加分页到printResult.pg ,当用户将页面Angular调用发布到服务器到下一个数据时。 我怎样才能做到这一点? 我的控制器: angular.module(‘PostService’, []) .controller(‘PageCtrl’, function ($scope, PostModel) { var srv = this; srv.offers = []; function postUrlToService(url) { $scope.dataLoading = true; $scope.printResult = null; initCreate(); PostModel.postUrl(url).then(function (result) { srv.offers = result.data; $scope.totalItems = srv.offers.pg; $scope.printResult = srv.offers; $scope.dataLoading = false; }); } function initCreate() { srv.newUrl = […]

在IE 11中更改图像的幻灯片速度无法正常工作,使用JS更新CSS动画属性

**此function用于控制脉冲速度动画,它适用于所有浏览器,IE 11和Edge(Windows 10)除外,脉冲速度没有正确降低。 ** 样式使用javascript动态变化,但样式更改的效果并未反映在IE 11和Edge浏览器的脉冲速度动画中。 function getPulseSpeed(param){ var speed= 3.5; var element = document.getElementById(“slideright”); var style = element.style; style.webkitAnimationPlayState = style.mozAnimationPlayState = style.oAnimationPlayState = style.animationPlayState = “paused”; if(param == 0){ speed = 3.5; style.webkitAnimationDuration = style.mozAnimationDuration = style.oAnimationDuration = style.animationDuration = speed + “s”; style.animationName = “x”; }if(param == 1){ speed = 2.5; style.webkitAnimationDuration […]