小编bee*_*est的帖子

angular2 testing:无法绑定到'ngModel',因为它不是'input'的已知属性

我正在尝试测试angular2双向绑定以进行控制input.这是错误:

Can't bind to 'ngModel' since it isn't a known property of 'input'.
Run Code Online (Sandbox Code Playgroud)

app.component.html

<input id="name" type="text" [(ngModel)]="name" />
<div id="divName">{{name}}</div>
Run Code Online (Sandbox Code Playgroud)

app.component.ts

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html'  
})
export class AppComponent implements OnInit {
  name: string;    
}
Run Code Online (Sandbox Code Playgroud)

app.component.spec.ts

import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { AppService } from './app.service';
describe('App: Cli', () => {
  beforeEach(() => {
    TestBed.configureTestingModule({
      declarations: [
        AppComponent
      ],
      providers:[AppService]
    });
  });

  it('divName', async(() => {
    let …
Run Code Online (Sandbox Code Playgroud)

testing angular-cli angular2-testing angular

87
推荐指数
1
解决办法
4万
查看次数

Angular2:ngModule,BrowserModule,FormsModule不是导出成员

我将通过https://angular.io/docs/ts/latest/tutorial/toh-pt5.html上的Angular2教程 .一切顺利的路由.Visual Studio代码显示前03行的错误:

import { NgModule }       from '@angular/core';
import { BrowserModule }  from '@angular/platform-browser';
import { FormsModule }    from '@angular/forms';
Run Code Online (Sandbox Code Playgroud)

[ts] 
Module '"c:/Users/ktran/Source/Repos/angular2-quickstart-ts/node_modules/@angular/core/index"' has no exported member 'NgModule'.
Run Code Online (Sandbox Code Playgroud)

文件夹node_modules:

在此输入图像描述

有什么想法吗?

angular

26
推荐指数
3
解决办法
4万
查看次数

aws-amplify js to angular app 有错误:全局未定义

我正在测试从 Angular 到 Cognito 用户池的 AWS Amplify,如下所示:

https://docs.amplify.aws/lib/restapi/getting-started/q/platform/js

Angular 应用程序已成功编译,但在 Chrome 控制台中抛出异常:

index.js:43 Uncaught ReferenceError: global is not defined
at Object../node_modules/buffer/index.js (index.js:43)
at __webpack_require__ (bootstrap:84)
at Module../node_modules/amazon-cognito-identity-js/es/AuthenticationHelper.js (AuthenticationHelper.js:1)
at __webpack_require__ (bootstrap:84)
at Module../node_modules/amazon-cognito-identity-js/es/index.js (index.js:1)
at __webpack_require__ (bootstrap:84)
at Module../node_modules/@aws-amplify/auth/lib-esm/Auth.js (Auth.js:1)
at __webpack_require__ (bootstrap:84)
at Module../node_modules/@aws-amplify/auth/lib-esm/index.js (index.js:1)
at __webpack_require__ (bootstrap:84)
Run Code Online (Sandbox Code Playgroud)

有什么想法吗?

amazon-cognito angular aws-amplify

6
推荐指数
2
解决办法
1452
查看次数

android.view.InflateException:二进制 XML 文件行 #2:二进制 XML 文件行 #2:错误膨胀类 android.support.design.widget.CoordinatorLayout

尝试在 Nexus 5x 中运行该应用程序时出现此错误。

\n\n

下面是堆栈:

\n\n
04-16 22:41:37.083 23199-23199/au.com... E/AndroidRuntime: FATAL EXCEPTION: main\n                                                                          Process: au.com.beewest.natswarehouse, PID: 23199\n                                                                          java.lang.RuntimeException: Unable to start activity ComponentInfo{au.com.beewest.natswarehouse/au.com....MainActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout\n                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)\n                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)\n                                                                              at android.app.ActivityThread.-wrap11(ActivityThread.java)\n                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)\n                                                                              at android.os.Handler.dispatchMessage(Handler.java:102)\n                                                                              at android.os.Looper.loop(Looper.java:148)\n                                                                              at android.app.ActivityThread.main(ActivityThread.java:5422)\n                                                                              at java.lang.reflect.Method.invoke(Native Method)\n                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)\n                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)\n                                                                           Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout\n                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:539)\n                                                                              at …
Run Code Online (Sandbox Code Playgroud)

android

5
推荐指数
1
解决办法
1万
查看次数

无法加载文件或程序集“Microsoft.IdentityModel.Tokens,版本=5.2.0.0

我正在尝试使用 VS 2015 将 OWIN JWT 添加到 webapi 项目中。参考显示Microsoft.Owin.Security.Jwt, Version=4.0.0.0Microsoft.IdentityModel.Tokens Version=5.3.0.0. 下面是运行时的错误。我5.2.0.0在源代码中找不到。

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.IdentityModel.Tokens, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///C:/Users/xxx/Documents/xxx/WebApi/
LOG: Initial PrivatePath = C:\Users\xxx\Documents\xxx\WebApi\bin
Calling assembly : Microsoft.Owin.Security.Jwt, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
Run Code Online (Sandbox Code Playgroud)

请问有什么想法吗?

jwt asp.net-web-api owin

5
推荐指数
1
解决办法
1万
查看次数

使用 Azure AD 通过 OAuth2 对 Azure API 管理进行身份验证

我正在尝试通过 AzureAD 使用 OAuth2 来保护 APIM API,方法是阅读以下文章:通过使用 Azure AD 的 OAuth 2.0 授权保护 Azure API 管理中的 Web API 后端

AzureAPIM - OAuth2

AzureAD - 后端应用程序:

  • 范围:文件.全部

AzureAD - 客户端应用程序:

对于演示会议 API,将验证 JWT 策略添加到入站处理,其中3a0cf09b-是租户 id,b7c31179-是后端应用程序应用程序 id: 在此输入图像描述

在开发人员门户中,AzureAD 身份验证成功并返回令牌: 在此输入图像描述

但是调用API授权失败: 在此输入图像描述

检查 jwt.io 中收到的令牌,我发现"aud": "00000003-0000-0000-c000-000000000000"不是后端应用程序应用程序 ID:

{
  "aud": "00000003-0000-0000-c000-000000000000",
  "iss": "https://sts.windows.net/3a0cf09b-xxx/", …
Run Code Online (Sandbox Code Playgroud)

oauth-2.0 azure-active-directory azure-api-management

5
推荐指数
1
解决办法
1万
查看次数

承担 Cognito 组的 IAM 角色

是否可以承担iam-role1链接到Cognito 用户池中的cognito-group1Cognito 用户的Cognito 组的 IAM 角色?cognito-user1cognito-user-pool1

我的配置:

Cognito 用户池cognito-user-pool1

  • Cognito 用户cognito-user1属于cognito-group1
  • Cognito 组cognito-group1已分配给iam-role1

Cognito 身份池cognito-identity-pool1

  • 身份验证提供商:cognito-user-pool1
  • 已验证角色 =iam-role1

我是:

  • IAM 角色iam-role1具有访问 S3 ReadOnly 的策略

此代码允许我向 Cognito 用户池进行身份验证:

AmazonCognitoIdentityProviderClient provider = new AmazonCognitoIdentityProviderClient();
            CognitoUserPool userPool = new CognitoUserPool("user-pool-id", "client-id", provider);
            CognitoUser user = new CognitoUser("cognito-user1", "client-id", userPool, provider);
            InitiateSrpAuthRequest authRequest = new InitiateSrpAuthRequest()
            {
                Password = "cognito-password1"
            };

            AuthFlowResponse authResponse …
Run Code Online (Sandbox Code Playgroud)

c# amazon-web-services amazon-iam amazon-cognito

4
推荐指数
1
解决办法
4144
查看次数

BrowserAuthError:interaction_in_progress:当前正在进行与 azure/msal-browser@2.11.2 的交互

尝试使用@azure/msal-react@1.0.0-alpha.6 和@azure/msal-browser@2.11.2 在 React 应用程序中登录重定向时出现此错误。登录数据正确返回,但在控制台中引发异常。

未捕获(承诺)BrowserAuthError:interaction_in_progress:交互正在进行中。请确保在调用交互式 API 之前已完成此交互。

import * as msal from "@azure/msal-browser";

const msalConfig = {
  auth: {
      clientId: '995e81d0-',
      authority: 'https://login.microsoftonline.com/3a0cf09b-',
      redirectUri: 'http://localhost:3000/callback'
  },
  cache: {
    cacheLocation: "sessionStorage", // This configures where your cache will be stored
    storeAuthStateInCookie: false, // Set this to "true" if you are having issues on IE11 or Edge
  }
};
const msalInstance = new msal.PublicClientApplication(msalConfig);
try {
  msalInstance.handleRedirectPromise()
    .then(res=>{
      console.log(res)
    })
    .catch(err => {
      console.error(err);
    });

  var loginRequest = {
    scopes: ["api://58ca819e-/access_as_user"] …
Run Code Online (Sandbox Code Playgroud)

reactjs azure-active-directory azure-ad-msal

4
推荐指数
4
解决办法
5916
查看次数

ssdt dacpac:如何防止 dacpac 在删除包含数据的表中的列时生成错误

我正在删除带有数据的表中的一列xxx。DACPAC 正在生成如下检查。

IF EXISTS (select top 1 1 from [dbo].[xxx])
    RAISERROR (N'Rows were detected. The schema update is terminating because data loss might occur.', 16, 127) WITH NOWAIT
Run Code Online (Sandbox Code Playgroud)

所有数据迁移均已在预部署脚本中完成。目前我已经手动注释掉了。

如何防止它自动生成?

sql-server dacpac sql-server-data-tools

3
推荐指数
1
解决办法
4564
查看次数

如何将HashLocationStrategy与Auth0 Lock小部件一起用于用户登录

更新后Auth0登录样品使用HashLocationStrategyapp.module.ts:

import { LocationStrategy, HashLocationStrategy } from '@angular/common';
// (...)
@NgModule({
  providers: [
    {provide: LocationStrategy, useClass: HashLocationStrategy},
    appRoutingProviders,
    AUTH_PROVIDERS
  ],  
//(...)
Run Code Online (Sandbox Code Playgroud)

Auth0 Lock authenticated事件不再被引发:

import { Injectable } from '@angular/core';
import { tokenNotExpired } from 'angular2-jwt';

// Avoid name not found warnings
declare var Auth0Lock: any;

@Injectable()
export class Auth0Service {

  // Configure Auth0
  lock = new Auth0Lock('I21EAjbbpf...', '....au.auth0.com', {});

  constructor() {
    // Add callback for lock `authenticated` event
    this.lock.on("authenticated", (authResult) => { …
Run Code Online (Sandbox Code Playgroud)

auth0 angular2-routing angular

3
推荐指数
1
解决办法
1608
查看次数

sorting the http get before returning to component

Currently in the service i am calling http.get as follow

getList(): Observable<Customer[]> {
return this.http.get<Customer[]>("api/customers");
Run Code Online (Sandbox Code Playgroud)

}

in component ngOnInit the list of customer is returned:

this.customerService.getList().subscribe(data => (this.customers = data));
Run Code Online (Sandbox Code Playgroud)

It is working fine. Now i want to sorting the list before returning to the component.

any idea of how to return sorted list in the service to compnent?

typescript angular

3
推荐指数
1
解决办法
47
查看次数

angular2 d3:将 d3 svg 鼠标位置更新为组件属性

D3 用于svgangular2组件中生成 a 。如何从 svg 事件更新属性xy组件mousemove

export class AxisComponent implements OnInit {
    x:number;
    y:number;     

    ngOnInit() {
        var svgWidth=400;
        var svgHeight=400;
        var margin = {top:25, right:25, bottom:50, left:50};
        var width = svgWidth - margin.left - margin.right;
        var height = svgHeight - margin.top - margin.bottom;

        var svg = d3.select('#container').append('svg')
            .attr('width', svgWidth)
            .attr('height',svgHeight)
            .style('border', '2px solid');

        svg.on("mousemove", function(){
            var xy = d3.mouse(this);

            this.x = xy[0]; 
            this.y = xy[0];
        });
}
Run Code Online (Sandbox Code Playgroud)

mousemove事件访问时出错:

在此处输入图片说明

svg d3.js angular

0
推荐指数
1
解决办法
1195
查看次数