小编Cod*_*-EZ的帖子

ExpressionChangedAfterItHasBeenCheckedError:表达式在检查后发生了变化.上一个值:'undefined'

我知道在stackoverflow中已经发布了很多相同的问题并尝试了不同的解决方案以避免运行时错误,但它们都不适用于我.

错误

组件和Html代码

export class TestComponent implements OnInit, AfterContentChecked {
    @Input() DataContext: any;
    @Input() Position: any;
    sampleViewModel: ISampleViewModel = { DataContext: : null, Position: null };
    constructor(private validationService: IValidationService, private modalService: NgbModal, private cdRef: ChangeDetectorRef) {
    }

    ngOnInit() {

    }
    ngAfterContentChecked() {

            debugger;
            this.sampleViewModel.DataContext = this.DataContext;
            this.sampleViewModel.Position = this.Position;

    }


<div class="container-fluid sample-wrapper text-center" [ngClass]="sampleViewModel.DataContext?.Style?.CustomCssClass +' samplewidget-'+ sampleViewModel.Position?.Columns + 'x' + sampleViewModel.Position?.Rows">
     //some other html here
</div>
Run Code Online (Sandbox Code Playgroud)

请注意:使用DynamicComponentLoader动态加载此Component

在我遇到麻烦之后,我发现了几个问题

首先,使用DynamicComponentResolver动态加载此子组件,并传递输入值,如下所示

 ngAfterViewInit() {
    this.renderWidgetInsideWidgetContainer();

  }


  renderWidgetInsideWidgetContainer() {
    let component = this.storeFactory.getWidgetComponent(this.dataSource.ComponentName);
    let …
Run Code Online (Sandbox Code Playgroud)

runtime-error angular

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

如何在webpack中生成动态导入块名称

我在我的打字稿代码中动态调用import语句,基于该webpack将创建如下的块:

在此输入图像描述

你可以看到Webpack自动生成的文件名分别为1,2,3,名称不是友好名称

我已经尝试过通过注释提供块名称的方法,但它正在生成 modulename1.bundle.js , modulename2.bundle.js

bootStrapApps(config) {

    config.apps.forEach(element => {

      registerApplication(
        // Name of our single-spa application
        element.name,
        // Our loading function
        () =>
          import(/* webpackChunkName: "modulename"*/  "../../" +
            config.rootfolder +
            "/" +
            element.name +
            "/" +

            "app.bootstrap.js"),
        // Our activity function
        () => true
      );
    });
    start();
}
Run Code Online (Sandbox Code Playgroud)

有没有办法通过此评论动态指定模块名称?我不知道这是打字稿还是webpack特有的.

typescript webpack webpack-4

13
推荐指数
1
解决办法
9696
查看次数

如何将IEumerable Collection添加到队列并在.NET中异步处理每个项目?

我已经创建了一个使用下面的交换服务器读取收件箱新消息的方法.如何将这些IEnumerable集合添加到队列并异步处理队列中的每个项目列表?

private static IEnumerable<ExchangeEmailInformation> GetInboxItems(ExchangeService service)
{
    var emailInformations = new List<ExchangeEmailInformation>();
    try
    {       
        SearchFilter searchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
        var itemview = new ItemView(int.MaxValue);
        FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, searchFilter, itemview);
        Console.WriteLine("\n-------------Result found:-------------");
        service.LoadPropertiesForItems(findResults, PropertySet.FirstClassProperties);

        foreach (var item in findResults)
        {
            emailInformations.Add(new ExchangeEmailInformation
            {
                Attachment = item.Attachments ?? null,
                Body = item.Body.BodyType == BodyType.HTML ? ConvertHtml.ToText(item.Body.Text) : item.Body.Text,
                Subject = item.Subject,
                RecievedDate = item.DateTimeReceived
            });
        }
    }
    catch (Exception ee)
    {
        Console.WriteLine("\n-------------Error occured:-------------");
        Console.WriteLine(ee.Message.ToString());
        Console.WriteLine(ee.InnerException.ToString());
        Console.ReadKey();
    }
    return …
Run Code Online (Sandbox Code Playgroud)

.net c#

12
推荐指数
1
解决办法
205
查看次数

LINQ to Entities无法识别方法'Int32 IndexOf(System.String,System.StringComparison)'方法

我已经使用如下的Entityframework执行了linq查询

GroupMaster getGroup = null;
getGroup = DataContext.Groups.FirstOrDefault(item => keyword.IndexOf(item.Keywords,StringComparison.OrdinalIgnoreCase)>=0 && item.IsEnabled)
Run Code Online (Sandbox Code Playgroud)

执行此方法时,我得到如下的异常

LINQ to Entities无法识别方法'Int32 IndexOf(System.String,System.StringComparison)'方法,并且此方法无法转换为商店表达式.

默认情况下包含()方法区分大小写,所以我需要转换为lower.Is有任何方法检查除contains方法之外的字符串匹配,是否有任何方法来解决indexOf方法问题?

.net c# linq entity-framework

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

如何在运行exe后返回退出代码?

我创建了一个用于验证函数的控制台应用程序,我需要使用vbscript执行此应用程序.执行此exe后,我想返回退出代码,无论函数是否返回成功.如何在.net中返回状态或退出代码?

.net vbscript

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

无法识别的配置部分

我创建了一个自定义配置部分,如下所示

 <configSections>
  </configSections>
  <Tabs>
    <Tab name="Dashboard" visibility="true" />
    <Tab name="VirtualMachineRequest" visibility="true" />
    <Tab name="SoftwareRequest" visibility="true" />
  </Tabs>
Run Code Online (Sandbox Code Playgroud)

自定义配置节处理程序

 namespace EDaaS.Web.Helper
    {
        public class CustomConfigurationHandler : ConfigurationSection
        {
            [ConfigurationProperty("visibility", DefaultValue = "true", IsRequired = false)]
            public Boolean Visibility
            {
                get
                {
                    return (Boolean)this["visibility"];
                }
                set
                {
                    this["visibility"] = value;
                }
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

运行应用程序时抛出异常 无法识别的配置部分选项卡.如何解决这个问题

.net asp.net asp.net-mvc

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

C#:使用可选参数和命名参数覆盖方法:意外结果

我有两个类FirstProcess和Second Process

public class FirstProcess
    {
        public virtual void Calculate(int x, int y)
        {
            Console.WriteLine("First Process  X :{0} and Y{1}", x, y);
        }
    }
    public class SecondProcess : FirstProcess
    {

        public override void Calculate(int y, int x)
        {
            Console.WriteLine("Second Process X :{0} and Y :{1}", x, y);
        }
    }
Run Code Online (Sandbox Code Playgroud)

我已经调用了如下的计算方法

  var secondProcess = new SecondProcess();
            var firstProcess = (FirstProcess) secondProcess;

            secondProcess.Calculate(x: 1, y: 2);
            firstProcess.Calculate(x: 1, y: 2);
Run Code Online (Sandbox Code Playgroud)

产量

第二个过程X:1和Y:2

第二个过程X:2和Y:1

我得到了意想不到的结果,X = 2和Y = 1.How .Net处理这种情况?为什么.net优先使用命名参数?

.net c#

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

将null值传递给重载方法,其中Object和String为C#中的param

我有两个重载方法,如下所示

 public class TestClass
    {

        public void LoadTest(object param)
        {
            Console.WriteLine("Loading object...");
        }
        public void LoadTest(string param)
        {
            Console.WriteLine("Loading string...");
        }

    }
Run Code Online (Sandbox Code Playgroud)

在调用此方法之后,它将显示输出为加载字符串...请解释.net如何处理此方案?

 class Program
    {
        static void Main(string[] args)
        {       
            var obj=new TestClass();
            obj.LoadTest(null);
           // obj.LoadType(null);
            Console.ReadLine();
        }
    }
Run Code Online (Sandbox Code Playgroud)

.net c#

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

在 C# 中使用对象初始值设定项时无法识别抛出异常的属性

在下面的两个示例代码中,我试图通过使用 C# 普通方法和对象初始值设定项来实例化一个名为Test的类。

DateTime? nullDate = null; //this value will come from somewhere else
DateTime? notNullDate = DateTime.Now;
var test = new Test();
test.Date = nullDate.Value; //exception will throw here
test.Name = "String";
test.AnotherDate = notNullDate.Value;
Run Code Online (Sandbox Code Playgroud)

在上面的示例代码中,我可以清楚地了解调试时哪个属性显示异常。

DateTime? nullDate = null; //this value will come from somewhere else
DateTime? notNullDate = DateTime.Now;
var test = new Test
{
    Date = nullDate.Value,
    Name = "String",
    AnotherDate = notNullDate.Value
};
Run Code Online (Sandbox Code Playgroud)

在上面的代码中,当我使用对象初始值设定项时,我无法理解抛出异常的属性。在这里,我无法逐行调试。如果我初始化了很多属性,则很难识别。

这是我的问题:如何从异常窗口识别哪个属性显示异常?现在内部异常为空。

在此处输入图片说明

c# exception object-initializers

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

Angular和Angular Dart - 建议哪种框架用于Web开发?

我对最新的Angular版本和Angular Dart之间的区别感到有点困惑.看起来两者具有相同的语法和实现风格.那么谷歌为新框架背后的意图是什么?我认为这对外界来说太混乱了.根据Angular Dart文档

AngularDart是一个Web应用程序框架,专注于生产力,性能和稳定性

根据我的理解,Angular也为Web开发提供相同的功能,主要关注性能.

任何人都可以帮助我理解 - 什么时候使用Angular Dart和Angular?我从堆栈溢出中看到了一个链接,它与Angular js相比较

Angular.js和Angular.dart之间的区别?

angular-dart angular

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