小编Tom*_*Tom的帖子

服务没有正确注入,页面显示没有结果+角度2

嗨,我正在创建一个Angular 2应用程序.似乎服务没有正确注入,因为我没有看到页面显示任何结果.我已将其设置risk-list.component.html为启动页面.有人能告诉我这是什么问题吗?
我也将代码上传到了一个plunker

app.module.ts

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent }  from './app.component';
import { RiskListComponent } from './components/risks/risk-list.component';

@NgModule({
    imports: [BrowserModule],
    declarations: [AppComponent, RiskListComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }  
Run Code Online (Sandbox Code Playgroud)

app.component.ts

import { Component } from '@angular/core';
import { DataTable, Column } from 'primeng/primeng';
import { Router } from  '@angular/router';
import {  Routes, RouterModule } from  '@angular/router';
import { WelcomeComponent } from  './components/home/welcome.component';
import …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angular2-services angular

8
推荐指数
1
解决办法
271
查看次数

TypeScript编译中缺少模块构建失败的ts.请通过'files'或'include'属性确保它在您的tsconfig中

我已将我的应用程序从角度4升级到角度6.我收到以下错误.我已经在tsConfig中添加了包含文件.我在运行ng测试时遇到错误.我想知道为什么当它包含在tsConfig中时,它会抱怨@wtw文件夹下的文件

"include": [
    "./src/**/*",
    "./node_modules/@wtw/**/*",
     "./node_modules/@types/**/*"
  ]
Run Code Online (Sandbox Code Playgroud)

错误信息

ERROR in ./node_modules/@wtw/platform/services/index.ts
Module build failed (from ../node_modules/@ngtools/webpack/src/index.js):
Error: C:\vstsprojects\testproject\testproject.ClientSide\node_modules\@wtw\platform\services\index.ts is missing from the TypeScript compilation. Please
make sure it is in your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an
issue in the library repository to alert its author and ask them to …
Run Code Online (Sandbox Code Playgroud)

angular

8
推荐指数
2
解决办法
7847
查看次数

容器宽度需要根据表格宽度动态变化

我试图为我的表实现一个容器,因此选择使用卡片类。从屏幕快照中可以看到,容器延伸到屏幕的整个宽度。我希望容器宽度基于表格的宽度。在我的情况下,表格的宽度可以随着数据水平呈现而改变。我如何使我的容器动态。如果水平滚动超出屏幕尺寸,则应出现水平滚动。正如您在下面的屏幕截图中所看到的,它环绕到下一行,并且顶部右侧有间隙

屏幕截图

在此处输入图片说明

html

<style>
    th,
    td {
        padding: 7px;
    }

   .scrollClass {
    overflow-x: scroll;
    }
    .fundClassesTable {
        margin: 0 auto;
        font-size: 11px;
        width: 100%;
    }

    .tableItem {
        text-align: center;
        border-left: solid 1px lightgrey;
        border-top: solid 1px lightgrey;
        border-right: solid 1px lightgrey;
        border-bottom: solid 1px lightgrey;

    }

    .rowItem:hover {
        background-color: #f5f7f7;
    }



    tr {
        display: block;
        float: left;
    }

    th,
    td {
        display: block;
        min-height: 46px;
        min-width: 300px;
    }

    label {
        margin-left: 0.5rem;
        vertical-align: middle
    }


    .panel-heading {
        color: white;
        background-color: …
Run Code Online (Sandbox Code Playgroud)

html css bootstrap-4

8
推荐指数
1
解决办法
184
查看次数

点击它时,Li元素不会保持选中状态

我创建了一个li项目,Html.ActionLink最终将其渲染为锚标记.我已经将CSS应用于悬停,它的工作原理非常好.

现在我需要li在点击它时突出显示该框.我使用过jQuery,但似乎没有用.我检查了调试器工具,似乎没有任何错误.所以我猜这个类没有得到应用.我不确定是什么问题.请参阅下面的代码.

$(document).ready(function() {
  $('#navcontainer ul li a').click(function() {
    $('.highlightMenu').removeClass('highlightMenu');
    $(this).addClass('highlightMenu');
  });
});
Run Code Online (Sandbox Code Playgroud)
#navcontainer ul {
  display: block;
  list-style-type: disc;
  padding-top: 40px;
  -webkit-margin-before: 1em;
  -webkit-margin-after: 1em;
  -webkit-margin-start: 0px;
  -webkit-margin-end: 0px;
  -webkit-padding-start: 40px;
}

#navcontainer ul li {
  display: inline-block;
  /*height: 50px;
        width:150px;*/
  border: 5px solid #009ddc;
  border-left: 5px solid #009ddc;
  border-right: 5px solid #009ddc;
  border-bottom: 5px solid #009ddc;
  border-top: 5px solid #009ddc;
  z-index: 0 !important;
  padding: 0;
  background: #fff;
  color: #24387f !important;
}

#navcontainer …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery html5

7
推荐指数
2
解决办法
1279
查看次数

固定列标题,同时水平滚动

我正在尝试修复列标题,以便可以水平滚动并看到标题。我已经尝试了以下方法,但似乎没有用。如果您在屏幕截图中看到,如果我上下移动屏幕,标题似乎都不会停留在一个位置,并且重叠不正确。第一个td总是隐藏在th后面。

屏幕截图1在此处输入图片说明

屏幕截图2 在此处输入图片说明

   th:first-child {
        position: fixed;

    } 

        th {
            position: fixed;
        }
.fixed-side {
    border:1px solid #000;
    background:#eee;
    visibility:visible;
}
Run Code Online (Sandbox Code Playgroud)

的CSS

<style>
    th,
    td {
        padding: 7px;
        min-width: 300px;
        max-width: 300px;
    }

    /* th:first-child {
    position: fixed;

} */


    th {
        position: fixed;
    }

    .fundClassesTable {

        table-layout: fixed;
    }


    .cellbgcolor {
        color: transparent;
    }

    .btn {}

    .tableItem {
        text-align: left;
        border-left: solid 1px lightgrey;
        border-top: solid 1px lightgrey;
        border-right: solid 1px lightgrey;
        border-bottom: solid 1px lightgrey;

    }

    .rowItem:hover { …
Run Code Online (Sandbox Code Playgroud)

html css angular

7
推荐指数
1
解决办法
382
查看次数

无法跟踪实体类型的实例,因为正在跟踪具有该键值的另一个实例

我基本上尝试使用 EntityFrameWork core 和 .Net core 3.1 来实现 CRUD。我的更新操作遇到问题,无法使用修改后的值更新上下文。我正在使用邮递员发起请求。

正如您在下面的代码中看到的,我试图检查该客户是否存在以及它是否确实将修改后的对象传递到上下文。

在此输入图像描述

功能码

   [FunctionName("EditCustomer")]
    public async Task<IActionResult> Run(
    [HttpTrigger(AuthorizationLevel.Anonymous,"post", Route = "update-customer")] HttpRequest req)
    {
        var customer = JsonConvert.DeserializeObject<CustomerViewModel>(new StreamReader(req.Body).ReadToEnd());
        await _repo.UpdateCustomer(customer);
        return new OkResult();
    }
Run Code Online (Sandbox Code Playgroud)

存储库方法

  public async Task UpdateCustomer(CustomerViewModel customerViewModel)
    {
        if (customerViewModel.CustomerId != null)
        {
            var customer = _context.Customers.Where(c => c.CustomerId.Equals(customerViewModel.CustomerId)).FirstOrDefault();

            if (customer == null)
            {
                throw new Exception("customer not found");
            }
            else
            {
                _context.Customers.Update(_mapper.Map<Customers>(customerViewModel));
                await _context.SaveChangesAsync();

            }
        }
       
    }
Run Code Online (Sandbox Code Playgroud)

测绘

   public class CustomerManagerProfile : Profile
    {
        public CustomerManagerProfile() …
Run Code Online (Sandbox Code Playgroud)

c# automapper entity-framework-core .net-core

7
推荐指数
2
解决办法
3万
查看次数

实体框架6错误serverversion:(System.Data.SqlClient.SqlConnection)customerOrderContext.Database.Connection).ServerVersion

我正在实现一个web api,它将使用实体框架6获取数据.我正在使用Sql Server 2014和visual studio 2015.While调试CustomerDao类中的代码我在customerOrderContext对象中看到一个异常,虽然我可以看到记录在客户对象中.然而,在使用块执行后,我无法看到任何记录.

((System.Data.SqlClient.SqlConnection)customerOrderContext.Database.Connection).ServerVersion

CustomerDao

using (var customerOrderContext = new Entities())
                {
                    return (from customer in customerOrderContext.Customers

                            select new CustomerOrder.BusinessObjects.Customers
                            {
                                Id = customer.Id,
                                FirstName = customer.FirstName,
                                LastName = customer.LastName,
                                Address = customer.Address,
                                City = customer.City,
                                Email = customer.Email,
                                Gender = customer.Gender,
                                State = customer.State,
                                Zip = customer.Zip
                            }).ToList();
                }
Run Code Online (Sandbox Code Playgroud)

配置文件中的连接字符串如下所示

<add name="Entities" connectionString="metadata=res://*/EF.CustomerOrderContext.csdl|res://*/EF.CustomerOrderContext.ssdl|res://*/EF.CustomerOrderContext.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=Tom-PC\MSSQLSERVER2014;initial catalog=Ransang;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
Run Code Online (Sandbox Code Playgroud)

上下文类如下

public partial class Entities : DbContext
{
    public Entities()
        : base("name=Entities")
    {
    }

    protected override …
Run Code Online (Sandbox Code Playgroud)

.net c# entity-framework asp.net-web-api entity-framework-6

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

HostListener onBlur 和 onFocus 没有在 angular4 中被触发

我在 angular 4 中编写了一个指令,用于捕获 onFocus 和 onBlur。我可以看到我的指令在加载表单时被初始化,但是当我单击输入控件时没有看到 obBlur 或 Onfocus 触发。不知道出了什么问题。我在输入元素上设置了 ShortNumberFormatterDirective

指示

import { Directive, HostListener, ElementRef, OnInit } from "@angular/core"; 
//import { MyCurrencyPipe } from "./my-currency.pipe"; 


 @Directive({ selector: "[shortNumberFormatter]" }) 
 export class ShortNumberFormatterDirective implements OnInit { 


   private el: HTMLInputElement; 


   constructor( 
     private elementRef: ElementRef, 
    // private currencyPipe: MyCurrencyPipe 
   ) { 
     this.el = this.elementRef.nativeElement; 
   } 


   ngOnInit() { 
     //this.el.value = this.currencyPipe.transform(this.el.value); 
   } 


   @HostListener("focus", ["$event.target.value"]) 
   onFocus(value) { 
     //this.el.value = this.currencyPipe.parse(value); // opossite of transform 
   } 


   @HostListener("blur", ["$event.target.value"]) 
   onBlur(value) { 
     //this.el.value = this.currencyPipe.transform(value); …
Run Code Online (Sandbox Code Playgroud)

angular

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

在升级到angular 7时,ngrx/store@6.1.0需要@ angular/core @ ^ 6.0.0的对等体

我试图将Angular 6应用程序迁移到angular 7应用程序,并得到以下警告消息

npm WARN @ngrx/effects@6.1.0 requires a peer of @angular/core@^6.0.0 but none is installed.
You must install peer dependencies yourself.
npm WARN @ngrx/store@6.1.0 requires a peer of @angular/core@^6.0.0 but none is installed.
You must install peer dependencies yourself.
Run Code Online (Sandbox Code Playgroud)

那是什么意思 ?

是否意味着没有角7的兼容商店?

我的商店不会工作吗?

angular ngrx-store peer-dependencies angular7

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

Angular 7 - ngx-spinner 覆盖整个页面

我已经在我的 angular 7 页面中实现了 ngx-spinner 并将全屏设置为 false,因为我不希望标题被微调器的背景颜色覆盖。渲染时它仍然覆盖整个页面。不确定是什么问题。

以下是我提到的链接

https://napster2210.github.io/ngx-spinner/

.alert {
    margin-top: 10px;
    height: 500x;
    position: relative;
    width: 100%;
    /* padding: 15px; */
    bottom: 0%;
    border: 1px solid transparent;
    border-radius: 4px;
    float: left;
}

.alert-danger {
    background-color: #f2dede;
    border-color: #ebccd1;
    color: #a94442;
}

table {
    border-collapse: collapse;
}

.spacing {
    padding-top: 0.5em;
    padding-bottom: 0.5em;
}

.k-tabstrip > .k-content.k-state-active {
    display: none !important;
}

Run Code Online (Sandbox Code Playgroud)
<div style="overflow-x: hidden; overflow-y: hidden;">
  <ngx-spinner bdOpacity=0.9 bdColor="#fff" size="medium" color="grey" type="ball-spin" fullScreen="false">
    <p style="color: white"> Loading... </p> …
Run Code Online (Sandbox Code Playgroud)

css angular ngx-spinner

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