假设我们定义了以下路由:
const routes: Routes = [
{
path: '',
component: WelcomeComponent
},
{
path: 'start',
component: StartComponent
}
Run Code Online (Sandbox Code Playgroud)
有没有办法告诉 Scully 跳过生成路由的静态页面start?
使用 Angular 13 以及ng-packagr当我们发布带有库的 SASS mixin 时,我们需要将该库添加到导出中package.json,并assets在ng-package.json.
这些是说明。
\nhttps://github.com/ng-packagr/ng-packagr/blob/main/docs/copy-assets.md
\n本期也对此进行了解释:\n SCSS @use 语句中的波浪号 ~ 自 Angular 13 起不再解析为 node_modules
\n所以我已经为这个项目做到了这一点:\n https://github.com/fireflysemantics/big-packaged-component-example
\n这是ng-package.json配置:
{\n "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",\n "dest": "../../dist/big",\n "assets": [\n "./src/CHANGELOG.md",\n "./src/lib/**/*.theme.scss"\n ],\n "lib": {\n "entryFile": "src/public-api.ts"\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n这是package.json配置:
\n \n{\n "name": "@fireflysemantics/big-packaged-component-example",\n "version": "0.0.7",\n "exports": {\n ".": {\n "sass": "./src/lib/big.component.theme.scss"\n }\n },\n "peerDependencies": {\n "@angular/common": "^13.3.0",\n "@angular/core": "^13.3.0"\n },\n "dependencies": …Run Code Online (Sandbox Code Playgroud) Angular Router 能够配置路由器以恢复滚动,并且链接的文档提供了如何在加载数据时执行此操作的示例。
我们如何配置独立路由器以将路由器出口滚动到顶部?
从这个演示中可以看出,在没有任何配置的情况下,如果两个视图都有可以滚动到底部的内容,如果一个视图确实滚动到底部,则在跨组件导航时视口将保持这种状态。
https://stackblitz.com/edit/angular-adcsej?file=src%2Fmain.ts
我使用此处的TomcatEmbeddedServletContainerFactory指令从http重定向到https:
http://drissamri.be/blog/java/enable-https-in-spring-boot/
但是,这会破坏对其余控制器的测试,即使它使用Application来运行不包含或引用执行重定向的TomcatEmbeddedServletContainerFactory配置的测试.
如果我从包含运行应用程序的@SpringBootApplication批注的Application中删除重定向配置,则测试通过.
知道如何在不破坏Rest控制器配置的情况下保持应用程序的生产配置到位吗?
TIA, - Ole
我正在阅读这个Spring安全教程,它提到我们可能会看到2个动态资源请求,因为这个控制器有一个CORS协商:
@SpringBootApplication
@RestController
public class UiApplication {
@RequestMapping("/resource")
public Map<String,Object> home() {
Map<String,Object> model = new HashMap<String,Object>();
model.put("id", UUID.randomUUID().toString());
model.put("content", "Hello World");
return model;
}
public static void main(String[] args) {
SpringApplication.run(UiApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
只是好奇这个@RestController注释是否默认启用CORS?
使用Spring安全性来保护带有oauth的API时,范围和角色之间有什么区别吗?
例如,当使用基于非oauth的基于角色的授权时,我可能有一个以john该角色命名的用户admin.
如果我正在使用oauth,那么它似乎john只会有范围admin.
我是否正确地思考这个问题?
本教程通过 NPM 运行 Gulp,如下所示:
// package.json
"scripts": {
"gulp": "./node_modules/gulp/bin/gulp.js"
},
// in your terminal, instead of using gulp, use npm run gulp
npm run gulp
Run Code Online (Sandbox Code Playgroud)
这同样有效吗:
// package.json
"scripts": {
"gulp": "npm run gulp"
}
Run Code Online (Sandbox Code Playgroud)
IIUC npm 会在node_modules/gulp/bin目录中查找 gulp 二进制文件吗?
我想以ng-content简单的字符串形式获取组件的innerText 以便能够重用它。
我尝试过这样的事情:
@Component({
selector: 'my-comp',
template: `
<div class="text-container">
<span class="text" [title]="text">{{text}}</span>
</div>
<ng-template #text>
<ng-content></ng-content>
</ng-template>
`
})
export class MyComponent implements AfterViewInit {
@ViewChild('text') text: TemplateRef<string>;
ngAfterViewInit(): void {
console.log(this.text);
}
}
Run Code Online (Sandbox Code Playgroud)
我这样使用它:
<my-com>
My simple string text
</my-com>
Run Code Online (Sandbox Code Playgroud)
目的是让我的字符串My simple string text进入变量text...
有什么想法吗?
我正在考虑编写一个验证器来检查一个值是否大于另一个值。例如购买价格大于销售价格。
但首先我们必须确保销售价格有效。所以我们可能有这样的事情:
class Product {
@IsNumber
@IsPositive
purchasePrice: Number;
@IsNumber
@IsPositive
@IsGreaterThan('purchasePrice')
salesPrice: Number;
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,@IsNumber和@IsPositive应该在@IsGreaterThan注释执行之前在两个属性上执行。
我想知道这是否易于实现(也许有一些类级别的元数据),或者我是否应该只编写简单的函数验证器来检查这种类型的东西。
我不是装饰器专家,但有人认为使用数字将验证元数据内置到每个装饰器中,以便验证器的执行按此数字排序。
因此,例如 @IsGreaterThan 验证器可以2分配一个数字,其他人分配一个数字1,这意味着验证器应该首先执行1标记的验证器,然后2.
javascript validation decorator typescript typescript-decorator
假设Object是可导入的东西,我们目前正在使用Object.getOwnPropertyNames.我们能做到:
import {getOwnPropertyNames} from 'Object';
Run Code Online (Sandbox Code Playgroud) typescript ×5
angular ×4
javascript ×4
java ×2
npm ×2
rest ×2
spring ×2
spring-boot ×2
angular-ivy ×1
decorator ×1
gulp ×1
ng-packagr ×1
node.js ×1
oauth2 ×1
sass ×1
scullyio ×1
seo ×1
spring-mvc ×1
transclusion ×1
validation ×1