草庐IT

angularjs-ng-pattern

全部标签

javascript - AngularJS - 创建服务对象

与其在Angular邮件列表中发帖,我认为这可能更多是关于javascript的问题。希望SO社区也能给出更快的响应。我正在尝试将数据封装在服务中并注入(inject)到Controller中。angular.module('myApp.services',['ngResource']).factory('Player',function($resource){varPlayer;Player={resource:$resource('/api/Player/:_id',{})};returnPlayer});functionPlayerDetailCtrl(Player,$route

javascript - 如何使用 ng-model 实现功能绑定(bind)(使用 plnkr)

我有一个dob列,其中的值采用yyyy-mm-dd格式,比如2013-01-01,我需要在输入框中显示1月1日。我可以通过编写一个函数来实现,然后从该函数返回精确值。但是无法使用ng-model从输入框中调用函数,因为它可以在span中使用ng-bind调用。我可以理解在输入框中调用函数会破坏双向绑定(bind)。但是我还可以使用什么其他方法。http://plnkr.co/edit/pZDpypsxM1OA2JwFhjjp?p=previewvarapp=angular.module('app',[]);app.controller('AppCtrl',function($scope

javascript - 我如何模拟 AngularJS 单元测试中 promise 的结果?

我的CompanyService是:angular.module('mean').service('CompanyService',['$http','$rootScope','$q',function($http,$rootScope,$q){varcompany=this;varinitializedDeferred=$q.defer();company.company_data={}company.initialized=initializedDeferred.promise;company.getCompany=function(){returncompany.company_

javascript - 触发 ng-model.$formatters 以编程方式运行

我想要一个使用ngModel.$formatters的自定义控件能够在加载服务器依赖项后立即格式化数据。在我的例子中,它需要加载一个查找表以从一种ID转到另一种。$modelValue存储一件事$viewValue显示另一件事。非常简单的东西。诀窍在于,如果我的查找表未加载,我将无法将格式设置为$viewValue。加载数据后,我需要执行以下操作:ngModel.$formatters.push(myFormatter)告诉ngModel从$modelValue->$formatters->$viewValue开始管道$render()不起作用,这只是将值从$viewValue移动到U

javascript - 带有 AngularJS 的 ChartJS - Canvas 不会显示任何内容

我正在尝试使用angular-chartjs图书馆,但遇到了一些问题。页面上没有错误。但是Canvas是空的。有人有想法吗?我试过几次重新排序脚本。我只是想不通。:(这是html。这是应用初始化:varapp=angular.module('profitly',['ngRoute','chartjs']);这是这部分的Controller:app.controller('graph',function($scope){$scope.someData={labels:['Supply','May','Jun'],datasets:[{data:[1,7,15,19,31,40]},{da

javascript - 在 Angularjs 中的 ng-keypress 上获取文本框的值

我想在按键时获取文本框的值。我有这样的html代码以及我Controller上的JS代码:$scope.myFunct=function(e){varcharCode=(e.which)?e.which:e.keyCode;//iwantherevalueofthetextbox} 最佳答案 Controller:$scope.myFunct=function(e,myValue){varcharCode=(e.which)?e.which:e.keyCode;//dosomethingwithmyValue}

javascript - AngularJS:在 ng-repeat 中调用 ng 样式函数时出现 $rootScope:infdig 错误

我正在尝试为一些短语制作动画,这些短语将显示在网站主页上,随机位置并具有淡入淡出和翻译效果。我将使用ng-style属性在ng-repeat属性内并设置调用HomeController内定义的JavaScript函数的ng-style值来实现此目的。使用此方法会导致Angular抛出异常:$rootScope:infdigerror10$digest()iterationsreached。中止!观察者在最后5次迭代中解雇我读了很多关于此的内容,但没有解决方案解决我的问题。谁能帮帮我?这是index.html的一部分:{{phrase}}Controller函数如下:$scope.get

javascript - 检查 ng-repeat 中的项目是否已经包含值

我在ng-repeat中绑定(bind)了问答的JSON字符串,现在的问题是我想在ng-repeat中一次显示所有多个答案。这是我的数据。{Answer:"White",AnswerID:967,answer_type:"RADIO",fullquestion:"YourRace",id:6}{Answer:"AfricanAmerican",AnswerID:968,answer_type:"RADIO",fullquestion:"YourRace",id:6}{Answer:"Asian",AnswerID:969,answer_type:"RADIO",fullquestion

javascript - 我如何在 Angularjs 中广播一个对象?

如何通过事件广播对象?目前我正在尝试:app.run($rootScope)->message={type:'channel',action:'create',data:{name:"ssss",id:0}}$rootScope.$broadcast('message',message)angular.module('WebChat').controller'ChannelController',($scope)->$scope.$on'message',(message)->console.logmessageconsole.log'hi'但是我没有得到输出编辑我让它工作了。好像回调

javascript - angularjs ng-class 方法被多次调用

在这个例子中,我有2个ng-class,每个调用不同的Controller方法,由于某种原因每个方法被调用3次,知道吗?可能的错误?varnavList=angular.module('navList',[]);navList.controller('navCtrl',['$scope','$location',function($scope,$location){$scope.firstClass=function(){console.log('firstClass');return'labellabel-success';};$scope.secondClass=function(