是否可以在独立组件中使用 Ngxs?我尝试NgxsModule通过以下方式导入:
@Component({
...
imports: [
...
NgxsModule.forFeature([MyState]),
...
Run Code Online (Sandbox Code Playgroud)
和
@Component({
...
imports: [
...
NgxsModule.forRoot([MyState]),
...
Run Code Online (Sandbox Code Playgroud)
但两者都给我以下错误消息:(Type 'ModuleWithProviders<NgxsFeatureModule>' is not assignable to type 'any[] | Type<any>'或NgxsRootModule在这种forRoot情况下)。还提供了更深入的错误消息:'imports' contains a ModuleWithProviders value, likely the result of a 'Module.forRoot()'-style call. These calls are not used to configure components and are not valid in standalone component imports - consider importing them in the application bootstrap instead.
这是否受支持,但我的语法错误?或者这是不支持的?如果不支持,拦截器是什么?
我.Split(',')在字符串上使用该方法,我知道该字符串由逗号分隔,我希望将这些值分开并放入string[]对象中.这适用于这样的字符串:
78,969.82,GW440,.
但是当第二个值超过1000时,值开始看起来不同,就像在这个例子中找到的那样:
79,"1,013.42",GW450,....
这些值来自电子表格控件,我在其中使用内置控件的ExportToCsv(...)方法,并解释了为什么实际数值的格式化版本.
有没有办法可以让.Split(',')方法忽略引号内的逗号?我实际上并不希望将值"1,013.42"拆分为"1和013.42".
有任何想法吗?谢谢!
我真的很想在不使用第三方工具的情况下这样做,因为我的用例实际上并没有涉及除此之外的许多其他情况,即使它是我工作解决方案的一部分,使用这样的工具并没有真正受益此刻的任何人.我希望有一些东西可以快速解决我丢失的这个特殊用例,但现在是周末,我会看到周一我能不能再给这个问题多一次更新了解决方案我最终来了起来.到目前为止,谢谢大家的帮助,我将在星期一进一步评估每个答案.
设置一个[...].DataSource对象的实例与一个类的类型有什么区别?我已经看到在我们的代码库中使用了这两种方法,并且我试图在这些情况下解决为什么它是这种或那种方式.
如何
object1.DataSource = typeof(SomeClass);
Run Code Online (Sandbox Code Playgroud)
与......不同
object2.DataSource = getSomeObject();
Run Code Online (Sandbox Code Playgroud)
另外,在第一种情况下,如果我将a设置DataSource为类的类型,那么如果该类是基类会发生什么?数据绑定是否适用于仅存在于从基类继承的类中的属性?或者数据绑定仅适用于我设置的类类型的类成员DataSource?
我很难写出我的Google搜索查询,以便回答这个问题.这要么是因为这些东西很复杂,我只是没有正确的措辞,或者我不太了解C#中数据绑定的一些基本原理.我可以在这里找到正确方向的帮助吗?谢谢!
我在尝试获取我正在从Web API检索的图像时遇到了很多麻烦,以便在我的Angular应用程序中显示为背景图像.
Web API返回图像的操作如下所示:
/// <summary>
/// Returns the medium image for the specified project as image/png media type.
/// </summary>
/// <param name="projectId"></param>
/// <returns></returns>
[HttpGet("{projectId:int}/image/medium")]
[SwaggerResponse(200, typeof(byte[]))]
[Produces("image/png")]
public FileContentResult GetImageMedium(int projectId)
{
var res = _repository.GetProjectResource(projectId, "Medium");
FileContentResult result = new FileContentResult(res.ByteContent, res.MediaType);
return result;
}
Run Code Online (Sandbox Code Playgroud)
这是我目前的Angular服务方法的样子(但我尝试了很多替代方案):
getProjectImage(id: number) {
return this._http
.get(`${this._url}/${id}/Image/Medium`, { headers: this._auth.headers, responseType: ResponseContentType.Blob })
.map(response => response.arrayBuffer());
}
Run Code Online (Sandbox Code Playgroud)
这就是我想要应用于[style.background-image]DOM元素的内容:
return `url(${'data:image/png;base64,' + new Buffer(response)})`
Run Code Online (Sandbox Code Playgroud)
正如我之前所说,我一直在尝试从我在互联网上找到的东西组合,但我对所涉及的大部分内容存在固有的误解.什么是我的Web API返回给我?我该如何处理该客户端?如何将内容按摩到适合background-imagecss属性的内容?除了让它发挥作用外,我真的想更好地理解这一点.非常感谢所有帮助!
我还试图更改Web …
我正在使用宝石pundit和devise.我有一个删除链接,只有在你是管理员时才显示.我有一个集成测试,我想验证删除链接只显示给管理员.
test 'comment delete link shows when it should' do
log_in_as @admin
get movie_path(@movie)
assert_select 'a[href=?]', movie_comment_path(comments(:one), @movie.id)
end
Run Code Online (Sandbox Code Playgroud)
我test_helper.rb看起来像这样:
...
class ActiveSupport::TestCase
...
def log_in_as(user, options = {})
password = options[:password] || 'password'
if integration_test?
post user_session_path, 'user[email]' => user.email, 'user[password]' => user.password
else
Devise::TestHelpers.sign_in user
end
end
private
# Returns true inside an integration test.
def integration_test?
defined?(post_via_redirect)
end
end
Run Code Online (Sandbox Code Playgroud)
该response.body看上去一切正常,但确确实实没有删除链接.当我运行开发服务器并自己访问该页面时,有一个.我已经把这个缩小到current_user政策中的权威人士使用的值为nil.这是我的comment_policy.rb:
class CommentPolicy
attr_reader …Run Code Online (Sandbox Code Playgroud) 我有一个依赖于dotnet核心Web api的angular应用程序,我想编写e2e测试,对各种资源执行CRUD操作,并验证angular应用程序正确响应了API中实现的响应/事件。我认识到,在很多情况下,人们都希望模拟后端,因为通常应以角度的方式进行e2e测试,以限制他们对确保前端表现相应的关注,而不是将前端和后端分开端应用程序一起正常运行。但这正是我想要做的。
是否有一种通用的方式来使前端e2e测试运行依赖于后端应用程序的本地实例化,该实例还可以还原数据库快照?此外,在考虑进行持续集成时,您是否仍将依靠CI计算机上后端应用程序的“本地”实例化,还是将其指向已在运行的测试服务器?另外,我开始考虑的替代方法是在API本身中引入一个端点,该端点可以还原我的angular e2e测试在每个测试结束时调用的数据库快照,afterEach(...)例如,例如。
我还考虑过使用内存中的db或仅模拟后端,但是该后端固有地缺乏在Web api中实现的特定行为,并且嘲笑该行为只是两次实现了该行为。
您或其他人为解决这个问题做了什么?
我目前有一个Rails 5应用程序作为我的后端,我们称之为"核心".我还有另一个Rails 5应用程序充当我的前端,它正在为AngularJS客户端提供服务,我们可以称之为"Front".这是两个完全独立的Rails 5应用程序,具有完全不同的域.
基本上,我正在尝试通过Core集成Action Cable,并让它与Front进行对话.我在这里使用此服务作为Front:https://www.npmjs.com/package/angular-actioncable.至于Core,这只是基本的Action Cable设置.
问题:我在让握手在两个不同的域中工作时遇到了一些麻烦.我已经阅读了我在网上找到的所有内容,遗憾的是没有太多信息.如果您以前这样做过,请帮忙!
注意:我确实运行了Redis服务器,并且我使用单独的端口来模拟开发中的单独域.
核心:
chat_channel.rb
class ChatChannel < ApplicationCable::Channel
def subscribed
stream_from 'http://localhost:2000/#/chat'
end
def unsubscribed
stop_all_streams
end
def receive(data)
ActionCable.server.broadcast('http://localhost:2000/#/chat', data)
end
def speak
params.fetch('data').fetch('chat')
end
end
Run Code Online (Sandbox Code Playgroud)
route.js
mount ActionCable.server => '/cable'
Run Code Online (Sandbox Code Playgroud)
cable.yml
development:
adapter: redis
url: redis://localhost:6379
test:
adapter: async
production:
adapter: redis
url: redis://localhost:6379
Run Code Online (Sandbox Code Playgroud)
配置/ environments.rb
config.action_cable.disable_request_forgery_protection = true
Run Code Online (Sandbox Code Playgroud)
面前:
ChatCtrl.js
app.controller('ChatCtrl', ['$scope', 'ActionCableChannel',
function($scope, ActionCableChannel) {
$scope.inputText;
$scope.chatData = [];
var consumer = new ActionCableChannel("ChatChannel");
var …Run Code Online (Sandbox Code Playgroud) 我已经设法让 @angular/fire 在 Angular 独立应用程序中工作,但我正在尝试像过去一样打开离线功能,现在我看到它已enableIndexedDbPersistence被标记为已弃用。它建议如下:
该功能将在未来的主要版本中删除。相反,将 FirestoreSettings.cache 设置为 IndexedDbLocalCache 的实例以打开 IndexedDb 缓存。当 FirestoreSettings.cache 已指定时调用此函数将引发异常。
我已经阅读了通常可以很好地解释如何使用 @angular/fire 的文档(https://firebase.google.com/docs/firestore/manage-data/enable-offline),但我没有看到关于做什么的任何明显指示。文档显示了如何使用传递到调用中的选项参数initializeFirestore,但 Angular 应用程序似乎没有在外部使用此方法(从开发人员的角度来看)。
我目前拥有的是以下内容:
export const appConfig: ApplicationConfig = {
providers: [
provideRouter(routes),
provideAnimations(),
provideServiceWorker('ngsw-worker.js', {
enabled: !isDevMode(),
registrationStrategy: 'registerWhenStable:30000',
}),
importProvidersFrom(
provideFirebaseApp(() =>
initializeApp({
// ... my info
})
),
provideAuth(() => getAuth()),
provideFirestore(() => {
const firestore = getFirestore();
enableIndexedDbPersistence(firestore); // Marked as deprecated :(
return firestore;
}),
provideStorage(() => getStorage())
),
],
};
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个使用电子重新加载和webpack进行实时重新加载的电子和角度应用程序。在我的package.json文件中,我先建立有角度的,然后运行电子,该电子运行主要过程并引导成角度的。为了启动该应用程序,我在单独的终端中一个接一个地运行命令:npm start和npm run electron。
应用程序正确启动;但是,当我向文件添加更改时,我的应用程序的电子部分保持不变,但我的应用程序的角部分丢失了。请帮忙。
{
"scripts": {
...
"start": "webpack --watch ",
...
"build-electron": "ng build --base-href . && tsc src\\electron\\electron-main.ts --outDir dist && tsc src\\electron\\logger.ts --outDir dist && tsc src\\electron\\application-menu.ts --outDir dist && copy src\\electron\\package.json dist && copy src\\electron\\*.html dist",
"electron": "npm run build-electron && electron ./dist --serve"
},
...
}
Run Code Online (Sandbox Code Playgroud)
Folder PATH listing for volume Windows
Volume serial number is 000000B3 D831:A351
C:.
| .angular-cli.json
| .editorconfig
| .gitattributes …Run Code Online (Sandbox Code Playgroud) 我正在尝试将大纲传输Microsoft Word 2010到Microsoft Excel 2010. 我正在使用DocumentFormat.OpenXml.Packing和Documentformat.OpenXml.Wordprocessing
我获取文档的正文,并使用它来获取所有段落对象的列表:
var allParagraphs = new List<Paragraph>();
WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open(wordDocPath.Text, false);
Body body = wordprocessingDocument.MainDocumentPart.Document.Body;
allParagraphs = body.OfType<Paragraph>().ToList();
Run Code Online (Sandbox Code Playgroud)
但我似乎找不到任何存储段落旁边的大纲编号的内容。除了文档中的段落之外,我是否需要抓取其他对象来获取每个段落的大纲编号(如果有的话)?
我所说的大纲编号出现在下面屏幕截图中这些标题的左侧:

不幸的ParagraphProperties.OutlineLevel是,即使我知道它是 word 文档中大纲的一部分,它也是空的。
angular ×5
c# ×3
actioncable ×1
angular-standalone-components ×1
angularfire ×1
angularfire2 ×1
angularjs ×1
base64 ×1
cross-domain ×1
data-binding ×1
datasource ×1
devise ×1
e2e-testing ×1
electron ×1
excel ×1
livereload ×1
ms-word ×1
ngxs ×1
openxml ×1
pundit ×1
snapshot ×1
split ×1
string ×1
webpack ×1
websocket ×1
winforms ×1