这是一个具有提交功能的控制器:
$scope.submit = function(){
$http.post('/api/project', $scope.project)
.success(function(data, status){
$modalInstance.dismiss(true);
})
.error(function(data){
console.log(data);
})
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的考验
it('should make a post to /api/project on submit and close the modal on success', function() {
scope.submit();
$httpBackend.expectPOST('/api/project').respond(200, 'test');
$httpBackend.flush();
expect(modalInstance.dismiss).toHaveBeenCalledWith(true);
});
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
Error: Unexpected request: GET views/appBar.html
Run Code Online (Sandbox Code Playgroud)
views/appBar.html是我的templateUrl:
.state('project', {
url: '/',
templateUrl:'views/appBar.html',
controller: 'ProjectsCtrl'
})
Run Code Online (Sandbox Code Playgroud)
所以不知何故,ui-router正在使我的$ httpBackend指向此而不是我的提交功能.在使用$ httpBackend的所有测试中,我遇到了同样的问题.
这有什么解决方案吗?
javascript angularjs angular-ui karma-runner angular-ui-router
我正在使用:https://github.com/angular-ui/ui-grid.info/tree/gh-pages/release/3.0.0-RC.18
<div ui-grid="gridOptions" style="height:765px"></div>
Run Code Online (Sandbox Code Playgroud)
当我对值进行硬编码时,如上所示,网格展开,一切都按预期工作.
但是,如果我做以下事情......
$scope.gridStyle = 'height:'+numRows*rowHeight+'px' //(765px);
<div ui-grid="gridOptions" style="{{gridStyle}}"></div>
Run Code Online (Sandbox Code Playgroud)
高度打印在div和div加宽,但内容本身扩大到只有340px左右.剩下的空间是空白的,所以不是25行我只看到8.我必须向下滚动,而网格中有400px的空闲.ui-grid-viewport和ui-grid-canvas都没有使用这个空间......
为什么ui-grid-viewport不能使用那个空间?
我想创建一个带有pre标签的bootstrap popover,其中包含一个美化的JSON对象.天真的实施,
<span popover='<pre>{[ some_obj | json:" " ]}</pre>'
popover-trigger='mouseenter'>
Run Code Online (Sandbox Code Playgroud)
在将内容插入弹出窗口之前将其转义.使用html内容指定弹出框体的最佳方法是什么?
angularjs angular-ui angular-ui-bootstrap angularjs-bootstrap
我使用AngularJS,$resource及$http与工作apis,但由于安全原因,我需要做(HTTPS协议下工作)的HTTPS请求.
https在AngularJS中使用的方法是什么.谢谢你的帮助.
我想在带有bootstrap的angularjs中选择一个占位符.我发现的解决方案不适用于角度
这是我的角度标记:
<select ng-model="myModel"
ng-options="p.name for p in ..."
class="form-control list-selector required">
<option value='' disabled selected>Please Choose</option>
</select>
Run Code Online (Sandbox Code Playgroud)
如果有人有工作解决方案......
谢谢 :)
我试图将ui.bootstrap依赖项添加到我的角项目中(我使用yeoman,bower).我这样做了:
然后我将ui.bootstrap依赖项添加到我的app.js:
angular.module('angularuiprojectApp', [
'ngCookies',
'ngResource',
'ngSanitize',
'ngRoute', 'ui.bootstrap'])
Run Code Online (Sandbox Code Playgroud)
当我尝试访问Chrome上的index.html时出现此错误:
未捕获错误:[$ injector:modulerr]由于以下原因无法实例化angularuiprojectApp模块:错误:[$ injector:modulerr]由于以下原因无法实例化模块ui.bootstrap:错误:[$ injector:nomod]模块'ui.bootstrap'是无法使用!你要么...... 1)
我不知道我错在哪里,如果有人可以帮助我...谢谢.
如果我有这个代码:
<accordion-group heading="{{group.title}}" ng-repeat="group in groups">
{{group.content}}
</accordion-group>
Run Code Online (Sandbox Code Playgroud)
使用AngularJS,angular-ui和Twitter Bootstrap,是否可以在打开时让手风琴调用一些动作?我知道我不能简单地添加ng-click,因为它已经被"编译"为HTML以用于打开/折叠组.
有一种方法可以在调用模态窗口后调用函数(无论是通过按钮还是通过单击背景)
var dialog, options;
options = {
windowClass: "lightBox"
templateUrl: "url to the template",
controller: "some random controller",
scope: $scope
});
$("body").css({
'overflow': 'hidden'
});
dialog = $modal.open(options);
dialog.result.then(function() {
$("body").css({
'overflow': 'auto'
});
});
Run Code Online (Sandbox Code Playgroud)
我希望每当模态窗口关闭结果中的函数时,然后执行promise.现在它只是在我手动关闭模态我的$ modalInstance.close()时执行.但如果我点击背景,这个方法就不会被调用
任何想法我怎么能这样做?
我想要2个日期选择器,我正在使用Angular UI版本0.11.0.
我的HTML代码
<span ng-if="periods.period == 10">
<input type="text" datepicker-popup="dd-MMMM-yyyy" ng-model="cdate.customStartDate" is-open="opened1" max-date="maxDate" datepicker-options="dateOptions" date-disabled="disabled(date, mode)" ng-required="true" close-text="Close" class="input-md" />
<button class="btn" ng-click="open($event,'opened1')"><span class="glyphicon glyphicon-calendar"></span></button>
</span>
<span ng-if="periods.period == 10">
-
<input type="text" datepicker-popup="dd-MMMM-yyyy" ng-model="cdate.customEndDate" is-open="opened2" min-date="cdate.customStartDate" max-date="maxDate" datepicker-options="dateOptions" date-disabled="disabled(date, mode)" ng-required="true" close-text="Close" class="input-md" />
<button class="btn" ng-click="open($event,'opened2')"><span class="glyphicon glyphicon-calendar"></span></button>
</span>
Run Code Online (Sandbox Code Playgroud)
我的JS代码是`
$scope.disabled = function(date, mode) {
return ( mode === 'day' && ( date.getDay() === -1 || date.getDay() === 7 ) );
};
$scope.maxDate = new Date();
$scope.open = …Run Code Online (Sandbox Code Playgroud) javascript datepicker angularjs angular-ui angular-ui-bootstrap
我正在使用Angular UI bootstrap模式对话框并在服务中创建它:
myApp.factory('ModalService', ['$modal', function($modal) {
return {
trigger: function(template) {
$modal.open({
templateUrl: template,
size: 'lg',
controller: function($scope, $modalInstance) {
$scope.ok = function() {
$modalInstance.close($scope.selected.item);
};
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
}
});
},
close: function() {
// this should close all modal instances
}
};
}]);
Run Code Online (Sandbox Code Playgroud)
ModalService.close()从控制器调用时,如何关闭所有模态实例?
angular-ui ×10
angularjs ×10
javascript ×5
bower ×1
datepicker ×1
jquery ×1
karma-runner ×1
node.js ×1