小编Ton*_*Ngo的帖子

嵌入 twitter 时间线不会以 angular 7 呈现

我正在关注https://help.twitter.com/en/using-twitter/embed-twitter-feed在角度页面中嵌​​入时间线。只有按钮呈现,而不是实际的时间线。

index.html的样子:

<body style="margin:0">
    <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
    <app-root></app-root>
</body>
Run Code Online (Sandbox Code Playgroud)

app.component.html如下所示:

<a class="twitter-timeline"
   href="https://twitter.com/TwitterDev/lists/national-parks?ref_src=twsrc%5Etfw">
      A Twitter List by TwitterDev
</a> 
Run Code Online (Sandbox Code Playgroud)

还尝试了app.component.ts 之类的东西

ngOnInit(){
   if ((<any>window).twttr.ready())
      (<any>window).twttr.widgets.load();
}
Run Code Online (Sandbox Code Playgroud)

但没有运气

node.js single-page-application typescript ecmascript-6 angular

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

在 ASP.NET Core 中实现 GraphQL(用于 .Net 的 GraphQL),为什么我的 Query:ObjectGraphType 类没有被依赖注入注册?

我已经设置了一个基本的 Web Api,演示了使用 ASP.Net Core 使用 GraphQL。我遵循了一个教程,感觉到底是什么,但遇到了一个我不明白的错误。

我正在为 .NET v2.4.0 使用 GraphQL

这是错误:

System.InvalidOperationException: No service for type 'Land.GraphQL.Queries.LandQuery' has been registered.
  at at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
  at at GraphQL.FuncDependencyResolver.Resolve(Type type)
  at at GraphQL.FuncDependencyResolver.Resolve[T]()
  at Land.GraphQL.LandSchema..ctor(IDependencyResolver resolver) in .../LandSchema.cs:11
Run Code Online (Sandbox Code Playgroud)

我将不胜感激任何灯光:)

这是代码:

我创建了一个 LandType:ObjectGraphType 来定义类型:

    public class LandType : ObjectGraphType<Entities.Land>
    {
        public LandType(ILandDataAccess landDataAccess)
        {
            Name = "Land";

            Field(land => land.Id, type: typeof(IdGraphType)).Description("Land Id in LandApi context");
            Field(land => land.Apn)
                .Description(
                    "Assessor's Parcel Number (APN) is a unique number that …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core-mvc .net-core graphql asp.net-core

6
推荐指数
1
解决办法
3200
查看次数

如何在 vue-cli 3.x 的监视模式下每个 webpack 自动构建后执行我自己的脚本?

我现在的情况

现在我正在使用 vue-cli@3.9.2。出于某种原因,我需要监视我的源代码的文件更改以运行 webpack 的构建,使用vue-cli-service build --watch.

我目前的解决方案

目前,我运行另一个 Node.js 进程来观察 webpack 包的文件更改。我真的遭受了这种可怕的开发经历。

与 vue-cli 2.x 对比

当我使用 vue-cli 2.x 时,我实际上运行webpack()了 webpack 的一个原生 API in build/build.js,因此我可以使用它webpack().watch()来运行 build 并将我自己的脚本作为回调函数传递。然而,在 vue-cli 3.x 中,据我所知,没有办法也不需要接近 webpack 的原生 API。

概括

我希望在 webpack 每次自动构建后运行我自己的脚本,尽管我在 vue-cli 的官方文档中找不到任何指导。

javascript node.js webpack vue.js

6
推荐指数
1
解决办法
4202
查看次数

ASP.NET Core 3.0 中获取当前经过身份验证的用户名的方法是什么?

我正在研究最新的 ASP.NET Core 3.0 Angular 模板。我需要知道的是我们如何在ActionFilterAttribute.

ClaimTypes.NameIdentifier返回当前用户ID,ClaimTypes.Name返回的用户名是空。

这是我的代码:

在此处输入图片说明

其中getUser有一个UserIdd15f997a-6f65-4eb2-aecb-8b525361ae50

我还在 Startup 类中注册了 IHttpContextAccessor,如下所示:

public IServiceProvider ConfigureServices(IServiceCollection services)
{
        services.AddDbContext<ApplicationDbContext>(options =>
            options.UseSqlServer(
                Configuration.GetConnectionString("DefaultConnection")));

        services.AddDefaultIdentity<ApplicationUser>()
            .AddEntityFrameworkStores<ApplicationDbContext>();

        services.AddIdentityServer()
            .AddApiAuthorization<ApplicationUser, ApplicationDbContext>();

        services.AddAuthentication()
            .AddIdentityServerJwt();

        //Database Setup
        services.AddDbContext<HashooDBContext>(Configuration.GetConnectionString("DefaultConnection"));

        services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

        services.AddControllersWithViews();
        services.AddRazorPages();
        // In production, the Angular files will be served from this directory
        services.AddSpaStaticFiles(configuration =>
        {
            configuration.RootPath = "ClientApp/dist";
        });

        return ContainerSetup.InitializeWeb(Assembly.GetExecutingAssembly(), services);
}
Run Code Online (Sandbox Code Playgroud)

控制器.cs:

[Authorize]
[ApiController]
[Route("api/[controller]/{companycode}")]
public class DashboardTransactionsController : ControllerBase
{ …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core-mvc .net-core asp.net-core asp.net-core-3.0

6
推荐指数
1
解决办法
7514
查看次数

当我们移动到角度 6 中的另一个组件时,如何销毁一个组件?

在角度 6 中,让我们有三个分量 x,y,z 。我现在在 x 组件。但是当我转到组件 y 并返回到 x 时,DOM 中仍然存在之前的 x 组件。但我想删除 x 的前一个实例。这意味着我一次只想要一个组件在 DOM 中的一个实例。如何做到这一点?

我的路由器配置部分:

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { OnlineideComponent} from './onlineide/onlineide.component';
import {HomepageComponent} from './homepage/homepage.component';

const routes: Routes = [
  {path: 'ide',component: OnlineideComponent},
  {path: '', component:  HomepageComponent }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
Run Code Online (Sandbox Code Playgroud)

javascript node.js typescript ecmascript-6 angular

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

Active Link为角选择了Nbular

我在尖角前端应用程序中使用星云,并希望设置选定的活动链接。我该如何实现?

我尝试过使用menuItem的selected属性,但是它仅应用于item对象,没有[routerLinkActive]选项

@Component({
  selector: 'nebular-pages',
  styleUrls: ['nebular.component.scss'],
  template: `
    <ngx-sample-layout>
      <nb-menu [items]="menu"></nb-menu>
      <router-outlet></router-outlet>
    </ngx-sample-layout>
  `,
})
export class NebularComponent {
  menu: NbMenuItem[];
  constructor() { }
        this.menu = [
          {
            title: 'Page1',
            link: `/user/params`,
            icon: 'nb-grid-b-outline',
            home: true,
          },
          {
            title: 'Page2',
            link: '/user/options',
            icon: 'nb-arrow-thin-right',
          },

          {
            title: 'Page3',
            icon: 'nb-list',
            children:[
              {
                title: 'Costs',
                link: '/user/costs',
                icon: 'nb-arrow-thin-right',
              },
              {
                title: "Benifits",
                link: "/user/benifits",
                icon: "nb-compose"
              },
            ]
          },

        ];
Run Code Online (Sandbox Code Playgroud)

angular nebular

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

如何使用 Angular 7 保持 AngularCLIServer 在 asp.net 核心上的构建之间运行

我正在使用 ASPNetCore 和 Angular 7。我的 Angular 应用程序变得越来越大,所以每次运行时重新编译 C# 代码和 Angular 代码变得很麻烦。

我的 Startup.cs 文件中有这一行。

  if (env.IsDevelopment()) {
     spa.UseAngularCliServer(npmScript: "start");
  }
Run Code Online (Sandbox Code Playgroud)

A. 是否有可能在我终止 ASPNet 应用程序时保持它运行,或者 B 单独运行它并仍然通过 aspnet 应用程序使用的相同 SSL 端口路由请求?

由于 angular 具有热模块替换功能,我只想保持 99% 的时间运行,并在更改 C# 代码时重新编译我的后端。

c# node.js asp.net-core-mvc asp.net-core angular

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

ReferenceError:全局未使用 web3 定义

一段时间以来,我一直在尝试将 Web3 安装到我的 Ionic v4 项目中。当我为项目提供服务时,它不断抛出错误。我收到一条错误,指出引用错误:全局未定义。

  1. 启动一个新的 Ionic 项目
  2. 安装 web3 : npm install --save web3
  3. 安装节点类型: npm install --save-dev @types/node
  4. 编辑一些代码来访问 web3 :
import { Component } from '@angular/core';
import { Web3 } from 'web3'; 

@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})
export class HomePage {

  web3 = new Web3(new Web3.providers.HttpProvider('https://rinkeby.infura.io/v3/apikey...'));

  constructor() {}

  test(){
    console.log(this.web3);
  }
}
Run Code Online (Sandbox Code Playgroud)
  1. 运行离子服务
  2. 编译成功,但我在谷歌浏览器的控制台中收到这样的错误
core.js:9110 ERROR Error: Uncaught (in promise): ReferenceError: global is not defined
ReferenceError: global is not defined
    at Object../node_modules/stream-http/lib/capability.js (capability.js:1) …
Run Code Online (Sandbox Code Playgroud)

javascript node.js typescript ionic-framework angular

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

指定从 ASP.NET Core WebApi 提供的 Angular ClientApp 的基本 URL

我创建了一个ASP.NET核心项目使用供应的角度应用services.AddSpaStaticFiles()app.UseSpaStaticFiles()app.UseSpa(),等。

但是它直接从 为应用程序提供服务http://localhost:1234,而我想从 提供它http://localhost:1234/angular/MyAngularApp1/,而我想http://localhost:1234/用于 API 控制器。

我怎样才能做到这一点?

注意:我需要它在生产版本中工作。某些解决方案似乎有效,但实际上它们仅在您从 Visual Studio 运行站点时才有效,并且在您发布/部署到 IIS 或 Kestrel 后停止工作。

c# asp.net-core-mvc .net-core asp.net-core angular

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

Webpack 和 svg-inline-loader 不起作用

我尝试svg-inline-loader在多页项目中使用。

当我在索引页面上使用它时它工作正常

    <%= require('!svg-inline- loader!../../img/toolbar/'+firstBtn.iconName+'.svg') %>
Run Code Online (Sandbox Code Playgroud)

但是当我尝试将它注入部分文件时,它不起作用。我得到

     Html Webpack Plugin:
     ReferenceError: require is not defined

    - lodash.templateSources[16]:7 eval
      lodash.templateSources[16]:7:50

    - loader.js:31 eval
      [search.html?..]/[html-webpack-plugin]/lib/loader.js:31:106

    - loader.js:36 module.exports
      [search.html?..]/[html-webpack-plugin]/lib/loader.js:36:3

    - index.js:422 
      [site.local]/[html-webpack-plugin]/index.js:422:16
Run Code Online (Sandbox Code Playgroud)

我的 webpack 配置

    {
      test: /\.html$/,
      include: [path.resolve('src/html/partials/')],
      use: ['html-loader']
        },           
      new HtmlWebpackPlugin({
       filename: 'index.html',
       template: './html/pages/index.html',
       chunks: ['main']
       }),
      new HtmlWebpackPlugin({
       filename: 'login.html',
       template: './html/pages/login.html',
       chunks: ['login', 'main']
       }),
      new HtmlWebpackPlugin({
       filename: 'search.html',
       template: './html/pages/search.html',
       chunks: ['main']
       }),
Run Code Online (Sandbox Code Playgroud)

我的搜索页面

     <% var toolbar = {
       firstBtn: {
       title: …
Run Code Online (Sandbox Code Playgroud)

javascript svg node.js ecmascript-6 webpack

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