我刚开始反应,我有点迷失.我正在尝试创建登录页面并发出http post请求.现在我只是想让任何类型的HTTP请求工作,所以我正在使用请求bin,我在npm包的文档中找到了这个基本操作(https://www.npmjs.com/package/redux -react-fetch):
export function updateTicket(ticketId, type, value){
return {
type: 'updateArticle',
url: `http://requestb.in/1l9aqbo1`,
body: {
article_id: ticketId,
title: 'New Title'
},
then: 'updateTicketFinished'
}
}
Run Code Online (Sandbox Code Playgroud)
所以,在写完一个动作之后,我该怎么办?我如何实际让我的应用程序调用并使用该操作?npm包的文档提到了在我的商店中设置状态的东西,我需要先设置一些东西吗?
我想在我的应用程序上添加Angular Material Paginator.
在模块中添加了MatPaginatorModule.
<mat-paginator #paginator
[length]="100"
[pageSize]="10"
[pageSizeOptions]="[5, 10, 25, 100]">
</mat-paginator>
Run Code Online (Sandbox Code Playgroud)
但它给出了一个错误:
未捕获错误:模板解析错误:
无法绑定到'length',因为它不是'mat-paginator'的已知属性.
mat-paginator
是Angular组件并且它有length
输入,则验证它是否是此模块的一部分.mat-paginator
是一个Web组件,然后添加CUSTOM_ELEMENTS_SCHEMA
到@NgModule.schemas
该组件来抑制此消息.
也许我错过了什么?
"@angular/animations": "^5.0.1",
"@angular/cdk": "^5.0.0-rc0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/material": "^5.0.0-rc0",
Run Code Online (Sandbox Code Playgroud) pagination angular-material2 angular angular5 angular-material-paginator
我是React的新手,我创建了一个显示用户名用户的导航栏
<NavItem eventKey={4} href="#">{this.state.name}</NavItem>
Run Code Online (Sandbox Code Playgroud)
但问题是如果用户没有登录,由于this.state.name未定义,我收到错误.有没有什么方法可以检查this.state.name是否在将其作为导航栏的一部分进行定义之前定义,还是有更好的方法来摆脱这个错误?
我有一个使用角项目mat-table
和mat-paginator
对于特定视图,问题是该视图具有网格视图和表格视图与肘节,网格视图是默认和表是使用NgIf时隐时现的网格视图是活动的。如果我将默认设置为表格视图,则分页工作正常,除非我切换到网格视图并返回,如果默认设置为网格,则在我切换到表格视图时会中断。我猜是因为当这段代码运行时表是隐藏的:
this.sliceList = new MatTableDataSource<Slice>(result);
this.sliceList.paginator = this.paginator;
Run Code Online (Sandbox Code Playgroud)
我尝试了控制台日志记录this.sliceList
,但sliceList.paginator
在默认网格视图时未定义,因此我认为这是问题所在。我怎样才能解决这个问题?
angular-material angular angular-material-table angular-material-paginator
我在角度应用程序上运行Karma测试,在测试中我有以下内容:
return inject(function($injector) {
this.Service = {
functionWithPromise: function(postdata){
var deferred = $q.defer();
deferred.resolve({
data: {}
});
return deferred.promise;
}
};
};
Run Code Online (Sandbox Code Playgroud)
和
it('should call the functionWithPromise function when the create function is called', function() {
res = {}
this.scope.create(res);
this.scope.$digest();
spyOn(Service, "functionWithPromise");
expect(this.Service.functionWithPromise).toHaveBeenCalled();
});
Run Code Online (Sandbox Code Playgroud)
当我运行测试时它会给出这个错误:
functionWithPromise() method does not exist
Run Code Online (Sandbox Code Playgroud)
如何让测试识别functionWithPromise()函数?
我有这个简单的测试:
describe('My Controller', function() {
beforeEach(function() {
module('myApp');
return inject(function($injector) {
var $controller = $injector.get('$controller');
this.rootScope = $injector.get('$rootScope');
this.scope = this.rootScope.$new();
this.controller = $controller('MyCtrl', {
'$scope': this.scope,
});
});
});
it('should have a controller', function() {
expect(this.controller).toBeDefined();
});
});
Run Code Online (Sandbox Code Playgroud)
控制器看起来像这样:
angular.module('myApp').controller('MyCtrl', ['$scope', '$state', '$filter', '$q', 'BookingService', 'ngToast', '$uibModal',
function($scope, $state, $filter, $q, BookingService, ngToast, $uibModal) {
$scope.bs = BookingService;
$scope.roundTrip = false;
$scope.reservationDetails = {};
$scope.originAddress = false;
$scope.destinationAddress = false;
$scope.reservationDetails.roundTrip = false;
$scope.seatReservationDepart = {};
$scope.charter = false; …
Run Code Online (Sandbox Code Playgroud) 我正在构建一个角度站点并使用UI-Router,如果我单击一个链接转到路由它工作正常但每当我刷新页面,或者如果我手动键入url我得到'无法获取/找到-a-供应商.我在我的路线文件中有这个:
$stateProvider
.state('home', {
url: '/',
templateUrl: 'views/home.html'
})
.state('find', {
url: '/find-a-vendor',
templateUrl: 'views/find.html'
})
Run Code Online (Sandbox Code Playgroud)
我也有$locationProvider.html5Mode(true);
我的路线文件.在我的索引中,我<base href="/">
在标题中,是否有我遗漏的东西?
我正在为客户建立一个网站,我正在使用预构建主题作为起点.它带有一个js文件,它有一个用于移动导航的点击功能,一切都运行正常,但是当我为jQuery添加一个脚本标签时,移动导航器坏了,控制台发出了这个错误:
Uncaught TypeError: Cannot set property 'onclick' of null
我该如何解决这个问题?导致错误的js行是document.getElementById('mobile-navigation').onclick = function(){
我尝试更改那一行以使用jQuery来选择元素,但这只是在js文件中导致了另一个错误.我怎样才能解决这个问题?
在HTML中:
<div id="navigation">
<span id="mobile-navigation"> </span>
<h1 class="nav-h1"><a href="index.html" class="logo"><!-- <img src="images/logo.png" alt=""> -->Header</a></h1>
<ul id="menu">
<li class="selected navList">
<a ui-sref="home">Home</a>
</li>
<li class="navList">
<a href="about.html">About</a>
</li>
<li class="navList">
<a ui-sref="find">Find a Vendor</a>
<!-- <ul>
<li>
<a href="runningsinglepost.html">Running single post</a>
</li>
</ul> -->
</li>
<!-- <li>
<a href="blog.html">Blog</a>
<ul>
<li>
<a href="blogsinglepost.html">blog single post</a>
</li>
</ul>
</li> -->
<li class="navList">
<a href="contact.html">Contact</a>
</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
js:
window.onload …
Run Code Online (Sandbox Code Playgroud) 我正在开发一个应用程序,我正在使用nodemailer发送恢复电子邮件给用户重置他们的密码,我正在尝试发送一个链接到一个允许他们更改密码的页面.我正在使用以下内容作为电子邮件的正文
html: '<p>Click <a href="localhost:3000/sessions/recover/' + recovery_token + '">here</a> to reset your password</p>'
Run Code Online (Sandbox Code Playgroud)
但是当我测试它时,我只是收到一封带有文本和没有链接的电子邮件,使用ispector显示<a>here</a>
,所以它发送了一个标签,它只是没有发送href.
我正在使用Angular UI和bootstrap,我正在使用uib-dropdown.我已将自动关闭设置为外部点击,但我还想在下拉菜单中创建一个关闭它的按钮.我尝试添加uib-dropdown-toggle
其中一个元素,但完全打破了下拉(它根本不会打开).如何创建关闭下拉菜单的元素?相关代码:
<div class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="btn-append-to-to-body">
<ul class="list-unstyled">
<!-- This is the button I want to close the dropdown -->
<li><button type="button" class="btn btn-default">X</button></li>
<li>...</li>
<li>...</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud) angularjs ×4
javascript ×3
angular ×2
reactjs ×2
angular5 ×1
html ×1
jquery ×1
jsx ×1
karma-runner ×1
node.js ×1
nodemailer ×1
pagination ×1
react-jsx ×1
react-redux ×1
redux ×1