我是Ionic2的新手,我正在尝试根据当前菜单选择构建动态标签.我只是想知道如何使用导航控制器获取当前页面.
...
export class TabsPage {
constructor(navParams: NavParams,navCtrl:NavController) {
//here I want to get current page
}
}
...
Run Code Online (Sandbox Code Playgroud)
从api文档我觉得getActiveChildNav()或getActive()将给我当前页面,但我不知道ViewController/ Nav.
任何帮助将不胜感激.提前致谢.
我在VMWare中的Linux上运行Apache.
我正在请求的一个PHP页面执行a sleep(),我发现如果我尝试在第一页请求第二页时sleep()'ing,第二页挂起,等待sleep()第一页完成.
有没有人见过这种行为?
我知道PHP不是多线程的,但这似乎是对CPU的严重错误处理.
编辑:我应该提到CPU使用率没有飙升.CPU"hogging"的意思是,当页面处于sleep()时,没有其他PHP页面能够使用CPU.
我试图从我的React Native App中保存一个对象.请查看以下代码段.
const { currentUser } = firebase.auth();
firebase.database().ref(`/users/${currentUser.uid}/employees`)
.push({ name, phone, shift })
.then(() => {
console.log('Save to Firebase was successful');
})
.catch((error) => {
console.log(error);
});
Run Code Online (Sandbox Code Playgroud)
但在Firebase控制台中,我什么都看不到.我很惊讶当时和捕获甚至没有被召唤.我错过了什么?控制台不显示任何错误.
我的Firebase数据库规则:
这是我的Firebase实时数据库视图:
问题 - 我正在推动/users/${currentUser.uid}/employees道路,我是否需要手动创建"用户"节点?
我创建了一个 API(带有 EF Core 的 .Net Core 2),带有一个端点来检索某些角色。我将 ASPNetIdentity 集成到我的项目中,并且我正在使用 AspNetRoles 和 AspNetRoleClaims。
在调用 API 时,用户在我的情况下具有特定的角色(管理员)。这个角色有几个角色声明。在 startup.cs 我为这个角色添加了策略:
options.AddPolicy(
"Create Roles", policy => policy.RequireClaim("Can create roles", "role.create"));
options.AddPolicy(
"View Roles", policy => policy.RequireClaim("Can read roles", "role.read"));
options.AddPolicy(
"Edit Roles", policy => policy.RequireClaim("Can update roles", "role.update"));
options.AddPolicy(
"Delete Roles", policy => policy.RequireClaim("Can delete roles", "role.delete"));
Run Code Online (Sandbox Code Playgroud)
在我的前端,用户可以使用他们的 Microsoft (azure) 帐户登录,并且他们的 oidc 声明 (ID) 与 AspNetUser 表中的 ID 匹配,如果在用户表中找不到他们的 oidc,则会自动添加他们(他们的 oidc id 为aspnetuser id),他们得到一个默认角色。
然而,在调用 Role 端点时,它总是返回 403 错误(禁止)。当我检查表时,用户具有访问端点的正确角色和角色声明。它怎么可能不断返回403?
端点如下所示:
[HttpGet]
[Authorize(Policy = …Run Code Online (Sandbox Code Playgroud) 我正在尝试以角度为我的应用程序进行基于角色的访问,我需要一些帮助,因为我是角度的新手......
\n\n首先,这是我在路线中确定哪些角色可以访问它的内容......
\n\n来自 app-routing.module.ts
\n\n{\n path: 'profile',\n component: ComunityComponent,\n canActivate: [AuthGuard],\n data: {\n allowedRoles: ['admin', 'user']\n }\n},\nRun Code Online (Sandbox Code Playgroud)\n\n其次,我使用 canActivate 函数来检查用户是否可以访问该路由。\n来自 auth.guard.ts
\n\nprivate hasAccess: boolean;\n\nconstructor(private router: Router, private auth: AuthService) {}\n\ncanActivate(next: ActivatedRouteSnapshot,\n state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {\n const allowedRoles = next.data.allowedRoles;\n if (localStorage.getItem('currentUser')) {\n return this.checkAccess(localStorage.getItem('currentUser'), allowedRoles);\n }\n\n this.router.navigate(['/login'], {queryParams: {returnUrl: state.url}});\n return false;\n }\nRun Code Online (Sandbox Code Playgroud)\n\n第三,我开发了 accessLoginToken 函数,它将通过 httpclient.get 服务查找登录用户的角色,该服务返回一个包含分配给用户的角色的数组。例子{success: true, roles:['user']}\n来自 auth.service.ts
accessLoginToken(token: string) {\n const check = …Run Code Online (Sandbox Code Playgroud) role-base-authorization typescript role-based-access-control angular auth-guard
我不明白 csproj 和引用是如何一起玩的。我创建了一个基本的 .Net Core 应用程序,它在本地构建得很好。但是当我尝试发布它时,我收到如下异常。
错误 NETSDK1047:资产文件“C:\Users\source\repos\AWSLambda7\AWSLambda7\obj\project.assets.json”没有“.NETCoreApp,Version=v3.1/linux-x64”的目标。确保恢复已运行并且您已在项目的 TargetFrameworks 中包含“netcoreapp3.1”。您可能还需要在项目的 RuntimeIdentifiers 中包含“linux-x64”。[C:\Users\source\repos\AWSLambda7\AWSLambda7\AWSLambda7.csproj]
下面是代码片段
public class Function
{
public async Task FunctionHandler(SQSEvent evnt, ILambdaContext context)
{
foreach (var message in evnt.Records)
{
await Task.CompletedTask;
}
}
}
Run Code Online (Sandbox Code Playgroud)
csproj 文件如下所示
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AWSProjectType>Lambda</AWSProjectType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="1.1.0" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.0.0" />
<PackageReference Include="Amazon.Lambda.SQSEvents" Version="1.1.0" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
obj\project.assets.json 文件如下所示
{
"version": 3,
"targets": {
".NETCoreApp,Version=v3.1": {
"Amazon.Lambda.Core/1.1.0": {
"type": "package",
"compile": {
"lib/netstandard2.0/Amazon.Lambda.Core.dll": {}
},
"runtime": { …Run Code Online (Sandbox Code Playgroud) 我正在使用 Angular 7 和 Angular CLI 版本 7.3.4。我正在对一个具有 2 个服务注入的组件进行单元测试,所有重要代码都包含在下面。我包含了导致错误的存根、规范文件以及相关组件的重要部分。尽管如此,我仍然收到此错误“TypeError:this.spreading.getSpreadingDays不是函数”我知道fixture.detectchanges()是导致ngOnInit被调用的原因,但应该定义该函数,因为我注入了服务。我确信这是一个愚蠢的错误,但我看过很多教程,但我无法弄清楚我的代码出了什么问题。任何建议,将不胜感激。
规格文件
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SpreadSignUpComponent } from './spread-sign-up.component';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { AuthService } from 'src/app/core/services/auth.service';
import { SpreadingService } from 'src/app/core/services/spreading.service';
import { AuthServiceStub } from 'src/app/core/testing/auth.service.stub';
import { SpreadingServiceStub } from 'src/app/core/testing/spreading.service.stub';
describe('SpreadSignUpComponent', () => {
let component: SpreadSignUpComponent;
let fixture: ComponentFixture<SpreadSignUpComponent>;
let authService: AuthService;
let spreadingService: SpreadingService;
beforeEach(async(() => {
TestBed.configureTestingModule({
providers: [
{ provide: AuthService, …Run Code Online (Sandbox Code Playgroud) unit-testing dependency-injection typescript ngoninit angular
我想创建一个我想要应用于类的属性.在这个类中,如果调用了一个方法,在postharp 的OnEntryand OnExitmethodof中,我想记录确切的方法名,如下所示:
"GetPartners开始......"
要么
"GetPartners完成......"
或者如果发生异常:
"在GetPartners方法中出现异常"
这有什么解决方案吗?
我通过命名的路由器出口将参数发送到我的ChildComponent. 但是在子组件中,当我尝试访问参数时,它们是未定义的。
这是路由配置文件
{ path: 'contact-hold/:id', component: OperationComponent, outlet: 'popup' }
Run Code Online (Sandbox Code Playgroud)
这是我的链接:
<a [routerLink]="['\',{outlets:{popup:['hold',1]}}]">Hold</a>
Run Code Online (Sandbox Code Playgroud)
这是浏览器中的样子:
/contact-list(popup:contact-hold/1)
Run Code Online (Sandbox Code Playgroud)
这是我保留的路由器插座AppComponent:
<router-outlet name="popup"></router-outlet>
Run Code Online (Sandbox Code Playgroud)
我在操作组件中像这样访问此参数:
this.route.queryParams.subscribe(params=> {
console.log(params["id"]);
})
Run Code Online (Sandbox Code Playgroud)
我已经解决了 stackoverflow 中的其他问题并实现了解决方案,但仍然不起作用。这段代码可能有什么问题?
angular ×4
c# ×3
typescript ×3
asp.net-core ×2
.net ×1
aop ×1
auth-guard ×1
aws-lambda ×1
azure ×1
datepicker ×1
firebase ×1
ionic2 ×1
javascript ×1
jwt ×1
ng-bootstrap ×1
ngoninit ×1
performance ×1
php ×1
postsharp ×1
sleep ×1
unit-testing ×1