Tag: angularjs

什么是用于angular度的$(双美元符号)?

我正在看1.2angular度的源代码,我只是好奇为什么一些函数前缀两个美元的标志。 这是一种约定吗?

为什么$只在'angular.mock.module'函数中可用,$ q只在'angular.mock.inject'函数中可用?

我正在嘲笑一个AngularJSunit testing的服务。 我正在使用$provide服务来replace模拟出来的“真实”服务(这是一个可用的plunker脚本 ): describe('My Controller', function () { var $scope; var $provide; beforeEach(angular.mock.module('myApp')); beforeEach(angular.mock.module(function (_$provide_) { $provide = _$provide_; })); beforeEach(angular.mock.inject(function($rootScope, $controller, $q){ var mockMyService = { getAll : function() { var deferred = $q.defer(); deferred.resolve([ { itemText: "Foo" }, { itemText: "Bar" } ]); return deferred.promise; } }; $provide.value('myService', mockMyService); $scope = $rootScope.$new(); […]

如何在AngularJSunit testing中模拟$ window.location.replace?

我有以下服务: angular.module("services") .factory("whatever", function($window) { return { redirect: function() { $window.location.replace("http://www.whatever.com"); } }; }); 如何在unit testing中模拟$window对象以防止在运行testing时重新加载页面? 我试过使用 spyOn($window.location, 'replace').andReturn(true); ,但它没有工作(仍然有"Some of your tests did a full page reload!"错误)和 $provide.value('$window', {location: {replace: jasmine.createSpy()}}) ,但我得到一个错误( Error: [ng:areq] Argument 'fn' is not a function, got Object )堆栈跟踪指向只有angular度自己的源,所以这是没有多大的帮助…

如何使用angular度平移进行unit testing

我从这里使用angular度翻译( http://pascalprecht.github.io/angular-translate/ ),它只是工作正常,但它打破了我的控制器的unit testingwhith错误: Unexpected request: GET scripts/i18n/locale-en.json 我不明白为什么? 我使用自我testing和业力。 app.js: 'use strict'; (function() { angular.module('wbApp', ['authService', 'authUserService', 'checkUserDirective', 'ui.bootstrap', 'pascalprecht.translate']) .config(function($routeProvider) { $routeProvider .when('/', { templateUrl: 'views/login.html', controller: 'LoginCtrl', access: { isFree: true } }) .when('/main', { templateUrl: 'views/main.html', controller: 'MainCtrl', access: { isFree: false } }) .otherwise({ redirectTo: '/' }); }); })(); configTranslate.js: […]

支持路由的AngularJS UI Bootstrap选项卡

我想在我的项目中使用AngularJS UI引导选项卡 ,但我需要它来支持路由。 例如: Tab URL ——————– Jobs /jobs Invoices /invoices Payments /payments 据我从源代码可以看出,目前的tabs和pane指令不支持路由。 什么是最好的方式来添加路由?

用Eclipse IDEconfigurationangularjs

我想开始使用AngularJs和Java Spring作为开发目的。我使用Eclipse作为IDE。 我想configuration我的Eclipse使这些框架无缝工作。 我知道我可能会问太多,但相信我,我已经做了很多的研究,你们是我最后的手段。任何帮助将不胜感激。

将数据传递给mdDialog

主列表页面有编辑button。 其中打开了编辑行的细节。 方式1:现在,如果我设置“ctrl.parent.q_details.client_location”,它绑定到父控制器,它作为双向绑定,并自动更改值在编辑框更改,这是不是要求在这里。 这里我只想在inputbox中显示和允许编辑值。 不想在父控制器中更改。 ►以下是父控制器中调用mdDialog的代码 $mdDialog.show({ locals:{parent: $scope}, clickOutsideToClose: true, controllerAs: 'ctrl', templateUrl: 'quotation/edit/',//+edit_id, controller: function () { this.parent = $scope; }, }); ►以下是popup的mdDialog的代码。 <md-dialog aria-label=""> <div ng-app="inputBasicDemo" ng-controller="deliverController" layout="column"> <form name="" class="internal_note_cont"> <md-content class="md-padding"> <md-input-container class="md-input-has-value" flex> <label>Client Name</label> <input ng-model="qe.client_name" required > </md-input-container> <md-input-container flex> <label>Client Location</label> <input required ng-model="ctrl.parent.q_details.client_location"> </md-input-container> </md-content> […]

AngularJS手动呈现控制器和模板

我正在试图在angularjs中实现一个插件系统,允许用户configuration他们将在某个页面上看到的“小部件”。 每个小部件由一个控制器和一个模板(url)定义。 是否有可能创build一个实例化控制器的指令,使用模板调用它并跨越结果内容? 目标是这样的: <div class="widget" ng-repeat="widget in widgets"> <widget controller="widget.controller" templateUrl="widget.templateUrl"></widget> </div>

AngularJS和ng-grid – 在单元格更改后自动将数据保存到服务器

我的使用案例非常简单。 用户在编辑Cell(enableCellEdit:true)之后,应该将数据“自动”发送到服务器(在单元模糊上)。 我尝试了不同的方法,但是他们都没有正确的解决。 我有一个简约的网格: // Configure ng-grid $scope.gridOptions = { data: 'questions', enableCellSelection: true, selectedItems: $scope.selectedRow, multiSelect: false, columnDefs: [ {field: 'id', displayName: 'Id'}, {field: 'name', displayName: 'Name'}, {field: 'answers[1].valuePercent', displayName: 'Rural', enableCellEdit: true} ] }; 例如,我试图观察传递给网格的数据模型。 但是这样做不会使编辑的单元格返回给我: $scope.$watch('myData', function (foo) { // myModel.$update() }, true); 我试图摆弄“ngGridEventData”数据事件,但它不会在单元格编辑后触发 $scope.$on('ngGridEventData', function (e, gridId) { // myModel.$update() }); […]

在加载时默认选中Angularjscheckbox,并在选中时禁用select列表

noob在堆栈溢出这里。 我正在一个具有传输工作function的网页上工作。 这样,用户可以选中一个checkbox将作业发送回办公室,或从所有可用列表中select一名技术人员。 我的问题是如何设置checkbox,以便在页面加载时默认选中,并相应地禁用select列表。 这里是我目前的代码: <div ng-app=""> Send to Office: <input type="checkbox" ng-model="checked" ng-checked="true"><br/> <select id="transferTo" ng-disabled="checked"> <option>Tech1</option> <option>Tech2</option> </select> </div> 这里是一个jsfiddle它: http : //jsfiddle.net/hugmungus/LvHJw/5/ 目前,页面加载与checkbox选中,但列表不禁用。 如果您取消选中,然后重新检查它,列表将被禁用。 谢谢您的帮助!