草庐IT

grunt-build-control

全部标签

javascript - 使用 Jasmine 测试 Angular Controller 中的非作用域函数

Jasmine是使用最广泛的测试框架之一,以BDD方式对javascript代码进行单元测试。我试图将它用于AngularJS组件测试。AngularJS文档提供了以下示例代码describe('PasswordController',function(){beforeEach(module('app'));var$controller;beforeEach(inject(function(_$controller_){$controller=_$controller_;}));describe('$scope.grade',function(){it('setsthestrength

javascript - Controller 的未知提供程序错误

这是我的app.js文件的样子://IonicStarterApp//angular.moduleisaglobalplaceforcreating,registeringandretrievingAngularmodules//'starter'isthenameofthisangularmoduleexample(alsosetinaattributeinindex.html)//the2ndparameterisanarrayof'requires'//'starter.controllers'isfoundincontrollers.jsangular.module('star

javascript - 如何在 Grunt 中使用 stylelint?

我正在尝试替换grunt-scss-lint(因为它的Ruby依赖性和未安装gem时的静默失败)与stylelint.我遇到的问题是以下错误:$gruntLoading"Gruntfile.js"tasks...ERROR>>ReferenceError:Mapisnotdefined我认为这是因为stylelint(它是一个PostCSS插件,而不是一个Grunt插件)需要ES6。Here'sthecodethat'sthrowingtheMapisnotdefinederror.有什么方法可以让它工作,我可以只运行grunt而不是一些奇怪的解决方法likethis?

javascript - 在 Controller 中使用它而不是 $scope

我正在尝试遵循Angular的风格指南,那里写道我们应该使用thisinstedscope...Styleguide当我能够使用this时,有人可以解释一下吗?这是我的尝试......我做错了什么?我正在尝试切换表单....这是我的html代码:REPLYCLOSE使用经典的$scope我会在我的Controller中这样做:$scope.formEdit=function(data){data.formEditShow=!data.formEditShow;}但是使用this它应该看起来像这样(但不起作用):varvm=this;vm.formEdit=formEdit;functi

javascript - 使用 Angular1+ ES6 时, Controller 函数中的依赖注入(inject)未定义, Controller 作为类

我正在使用ES6类来定义我的Controller,所以这是语法,exportclassSearchBarController{constructor($log){'ngInject';$log.debug("Hello");}textTyped($log){$log.debug("changefired.");}}查看:因此,构造函数中的“Hello”已被正常记录。但是,typedText()函数中的“changefired”并未触发,因为显然未定义如何让我的类函数textTyped()访问$log服务?注意:如果我在构造函数中将$log分配给类属性,例如,this.logger=$l

javascript - 单击时如何从 Controller 获取数据到指令

当我使用ng-clicked时,我试图从Controller将数据发送到指令链接函数,但是我未能将数据发送到指令,该指令在页面加载时调用第一次这是我的html代码click这是我的Controller.controller('myController',function($scope){$scope.clickMe=function(somedata){$scope.myVal=somedata;};});我的指令.directive('myDirective',function(){return{restrict:'E',scope:{myKey:'='},templateUrl:'

javascript - 将 Javascript 数组传递给 ASP.NET MVC Controller

我有以下javascript类,我正试图将其传递给ASP.NETMVCControllervarpostParams={attributes:[{name:'',description:'',attributeType:'',value:''}]};postParams.attributes[0]=newObject();postParams.attributes[0].name="test";postParams.attributes[0].description="test";postParams.attributes[0].attributeType="test";postPar

c# - 从 mvc Controller 设置一个 javascript 变量

是否可以从C#Controller设置JavaScript变量?我们有一种情况,我们用不需要用户登录的愚蠢版本覆盖我们的母版页。但是,我们的javascript超时计时器仍在运行。我想在重写master的Controller方法中,将超时重写为巨大的东西。publicdumbDownController(){ViewData["MasterPageOverride"]="~/Views/Shared/_NoLogin.cshtml";//Somehowresetthattimerbelowfrom20tolike9999.Tosimulatenotimeout.returnView("

javascript - grunt.task.run() 不工作

我正在尝试在我的express应用程序中使用grunt。我有这样的东西:vargrunt=require('grunt');require(process.cwd()+'/gruntfile.js')(grunt);grunt.task.run('development');但是这个任务好像不行。(没有错误输出到控制台)但是,如果我直接在控制台“gruntdevelopment”中运行,它就可以正常工作。 最佳答案 grunt.task.run只是将一个任务添加到队列中,因此它可以在现有任务中运行,但不能在外部脚本中运行。这是我从g

javascript - jQuery Ajax 无法调用 MVC 4 Controller 方法

我正在尝试使用jQuery以便在单击某个按钮后触发Ajax调用。我已经阅读了几个语法示例和可能遇到的问题,但未能找到适合我的原因的有效解决方案。这是代码。Controller方法:(HomeController.cs)[HttpPost]publicJsonResultChangeCompany(stringcompanyCode){returnJson(new{result=companyCode},JsonRequestBehavior.AllowGet);}jQuery代码:functionchangeCompany(company){$.ajax({url:'@Url.Acti