我想在asp.net core 2.0 SPA中添加一个新组件,角度为4,角度为cli,此版本:
@ angular/cli:1.4.2
节点:8.4.0
os:Linux x64
当我ng g c vehicle-form在组件目录上运行此命令时出现此错误:
错误:找不到新组件的NgModule.使用skip-import选项跳过导入NgModule中的组件.找不到新组件的NgModule.使用skip-import选项跳过导入NgModule中的组件.
另外,我有3个文件而app.module.ts不是一个:\:
app.module.browser.ts
app.module.shared.ts
app.module.server.ts
我刚刚开始使用 C# 9 和 .NET 5.0,特别是新record结构。我发现我有很多关于记录类型速记语法的优秀用例。
我考虑过的用例之一是对 ASP.NET Core 应用程序使用recorddto in IOptions<>,而不是常规类。这些选项类通常很简单,所以我认为它非常适合,但似乎我不能让它轻松工作,因为使用配置应用程序IOptions<>需要对象具有无参数构造函数。
public record MyOptions(string OptionA, int OptionB);
public class Startup
{
public void ConfigureServices(IServiceCollection services) {
services.Configure<MyOptions>(Configuration.GetSection(nameof(MyOptions)));
}
...
}
public class MyController : Controller
{
private readonly MyOptions _options;
public MyController(IOptions<MyOptions> options) {
_options = options.Value; // This throws an exception at runtime
}
}
Run Code Online (Sandbox Code Playgroud)
上面的示例在尝试访问该IOption<>.Value属性时抛出以下异常:
System.MissingMethodException: '没有为类型 'AcmeSolution.MyOptions' 定义无参数构造函数。
有没有办法配置IOptions配置系统以使用记录的构造函数反序列化选项,而不是需要无参数的构造函数?
我可以对记录使用普通语法,但是使用类确实没有任何好处。
题
如何使用SQL CE 4.0创建内存数据库?
上下文
我想用真实的数据库进行一些单元测试(或自动集成测试),然而,这是一个在内存中的数据库.这将使测试运行得更快,而且,一旦测试完成,数据库将在空气中消失.
根据Scott Guthrie的博客文章" VS 2010 SP1和SQL CE ",新的SQL CE 4.0能够做到这一点:提供内存数据库.
但是,我在网上找不到任何教程或代码示例,显示它是如何完成的.我在这篇博文中只发现了这个连接字符串示例.但这也击中了硬盘.

我刚刚使用(推荐)资源管理器部署模型在Microsoft Azure中创建了一个新的Ubuntu 14.04虚拟机.以下屏幕截图显示了部署配置和结果资源:
部署之后,我通过公共IP使用SSH访问VM,登录并安装了nginx.我使用默认配置保留它并执行'curl localhost'以确保Web服务器正在运行.
然后,我转到了Network Security Group资源,并为端口80添加了允许规则到入站规则:
然后我打开浏览器并尝试请求与NIC关联的公共IP并获得连接超时.
编辑:我可以通过取消NSG与NIC的关联来获取访问权限,但如果我重新关联它,我将在几分钟内再次被阻止.
我尝试使用相同的过程来设置带有IIS的Windows Server VM,但我得到了相同的结果.
我在这里错过了什么?
使用经典部署模型进行相同设置时,我没有遇到任何错误,这只在尝试推荐的资源管理器模型时发生.
azure azure-virtual-machine azure-virtual-network azure-resource-manager
我正在尝试使用动态编译Angular组件$compile,但是范围不会传递给组件范围,而是传递给$ parent范围.
这是一个绑定到myTitle-attribute并呈现它的简单组件:
app.component('myComponent', {
bindings: {
myTitle: '<'
},
template: `
<div>
<div>Doesn't work: {{ $ctrl.myTitle}}</div>
<div>Works: {{ $parent.$ctrl.myTitle}}</div>
</div>`
});
Run Code Online (Sandbox Code Playgroud)
然后在控制器(或指令等)中使用$ compile编译它:
app.controller('MainCtrl', function($scope, $element, $compile) {
var template = '<my-component></my-component>';
var bindings = {
myTitle: 'My Title'
}
var scope = angular.extend($scope.$new(true), {
$ctrl: bindings
});
var newElement = $compile(template)(scope);
$element.append(newElement);
});
Run Code Online (Sandbox Code Playgroud)
运行时,它会产生结果:
不起作用:
作品:我的头衔
为动态创建的组件创建的范围如何作为组件的父范围传递?
关于角度为何如此行为以及可能如何避免它的任何指针都非常受欢迎.
我的cordova离子1代码目前加载所有rss feed,这导致我的页面太长,因为rss源太多.
因此,我只想在预设中显示前三个rss项目(处于崩溃状态).当在"更多"点击,它就会展开并显示所有项目.再次单击,它将折叠并仅显示第一个rs.
目前,没有rss项目显示崩溃状态.它显示所有处于可扩展状态.
我需要的是:
显示前三个rss项目,按崩溃状态排序日期(最新).
在可扩展状态下显示所有rss项目.
我的模板
<div class="card">
<div class="item item-divider">RSS</div>
<a class="item item-icon-right" ng-if='showmore' ng-repeat="item in rssNews| orderBy: 'pubDate':true" ng-click="openitems(item.link)">
<h2>{{item.title}}</h2>
<h6>{{item.pubDate}}</h6>
<p {{story.description | htmlToPlaintext}}</p>
</div>
</a>
<div ng-click="togglemore()" <i class="icon" ng-class="showmore ? 'ion-android-remove-circle assertive' : 'ion-android-add-circle positive'"></i><span class="padding" ng-bind="showmore ? 'Less' : 'More'"></span></div>
</div>
Run Code Online (Sandbox Code Playgroud)
angularjs
$scope.showmore = false;
$scope.togglemore = function() {
$scope.showmore = !$scope.showmore;
};
Run Code Online (Sandbox Code Playgroud)
崩溃条件.初始状态.(看蓝色的'+'号).没有显示任何RSS.我想要显示前3个RSS源.
展开条件.它将显示所有rss提要.
例如,rss feed链接如下
https://www.google.com/finance/company_news?q=KLSE:AEON&ei=pKh8WfndJ9G8uQTKgKq4CQ&output=rss
另一个JS
$webServicesFactory.get(
"https://www.google.com/finance/company_news",
{},
{
output: "rss",
q: 'KLSE' + …Run Code Online (Sandbox Code Playgroud) 我得到了一个可编辑的单行标题,如下所示:
<h1 class="headline" contenteditable="true" [textContent]="headline.name" (input)="headline.name=$event.target.textContent" (keydown.enter)="submit();false">
Run Code Online (Sandbox Code Playgroud)
但是,当我按Enter键时,输入字段将保持其焦点。如何使它失去对输入的关注?
我有一个"有趣"的问题,如果log4net来自ASP.NET MVC中的工作线程,它们不会写日志消息.当我添加<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />到我的log4net配置以及网站在我的服务器(IIS 8.0)上运行时,这似乎只是一个问题.在我自己的计算机上,log4net可以很好地记录消息 - 即使使用MinimalLock配置,如果我删除了这个'MinimalLock',它也会在服务器上的工作线程中记录消息.
这是一个例子:
public class MvcApplication : System.Web.HttpApplication
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
protected void Application_Start()
{
// This is logged just fine - with or without MinimalLock,
// both local and on server
log.Info("Logging ouside worker!");
// This is only logged without MinimalLock configured
// if the site is hosted on my server runnning IIS 8.0.
var thread = new Thread(() => log.Info("Logging inside worker!"));
thread.Start(); …Run Code Online (Sandbox Code Playgroud) 我使用此处描述的yo生成器模板生成一个ASP.NET Core应用程序,其中Angular2作为前端.但随机地,在更改css文件并保存它们(导致Webpack重新加载)后,我在客户端控制台中得到以下异常:
Uncaught ReferenceError: vendor_bd98b4ed288c6b156cc9 is not defined
at Object.<anonymous> (external "vendor_bd98b4e…":1)
at __webpack_require__ (bootstrap 4cd8e17…:659)
at fn (bootstrap 4cd8e17…:83)
at Object.module.exports (eventsource.js from dll-reference vendor_bd98b4e…:1)
at __webpack_require__ (bootstrap 4cd8e17…:659)
at fn (bootstrap 4cd8e17…:83)
at Object.<anonymous> (main-client.js?v=4atoLMuOmZwmyVdq2ky2bYoBjkmqmVnuPNSIFOD8Qjs:2625)
at __webpack_require__ (bootstrap 4cd8e17…:659)
at module.exports (bootstrap 4cd8e17…:708)
at bootstrap 4cd8e17…:708
Run Code Online (Sandbox Code Playgroud)
在dist/main-client.js文件中我找到了以下行:
module.exports = vendor_bd98b4ed288c6b156cc9;
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = (__webpack_require__(0))(0);
Run Code Online (Sandbox Code Playgroud)
当我删除整个wwwroot/dist文件夹并重建Webpack包时,错误就消失了.然后,随机字符串改变如下:
module.exports = vendor_9dc79ae12948ed5e4b95;
Run Code Online (Sandbox Code Playgroud)
似乎是某种缓存问题.是什么导致这个?
我正在使用Webpack 2.2.1版.
是否可以创建可以从组件和视图访问的全局变量?
目前我创建了一个像这样的global.ts文件:
export const GlobalVariable = Object.freeze({
BASE_API_URL: 'http://www.asdf.com/'
});
Run Code Online (Sandbox Code Playgroud)
然后我必须在每个组件中导入它:
import { GlobalVariable } from '../shared/global';
Run Code Online (Sandbox Code Playgroud)
然后我可以在这些组件中使用"GlobalVariable.BASE_API_URL".我不喜欢它有两个问题.首先,我必须在每个组件中导入它的部分,是否可以对所有组件进行一次导入?但实际上这是我可以忍受的问题.更大的问题是我似乎可以在我的html文件中访问该变量.这有解决方案吗?
angular ×4
c# ×3
angularjs ×2
javascript ×2
angular-cli ×1
azure ×1
c#-9.0 ×1
cordova ×1
html ×1
log4net ×1
record ×1
typescript ×1
webpack ×1
webpack-2 ×1