我想绘制4个圆圈,所有4个弹性项目,我需要它们与它们所在的容器一起扩展.我已经看到了一些使用的解决方案padding-bottom,但我无法理解它.
我设法得到了我想要的特定结果width和heightflex-items.任何人都可以这样做但没有它并在我的HTML中保持相同的结构?
.container {
display: flex;
flex-wrap: nowrap;
width: 200px;
height: 50px;
}
.holder {
margin-right: 5px;
width: 30px;
height: 30px;
border-radius: 50%;
}
.h1 {
background: blue;
}
.h2 {
background: red;
}
.h3 {
background: green;
}
.h4 {
background: grey;
}Run Code Online (Sandbox Code Playgroud)
<div class="container">
<div class="holder h1"></div>
<div class="holder h2"></div>
<div class="holder h3"></div>
<div class="holder h4"></div>
</div>Run Code Online (Sandbox Code Playgroud)
我正在设计一个API Rest服务,允许用户将文件上传到服务器.
我认为这是一个PUT请求,它将转到server/resource/ID并将文件作为base64放在json请求体中.
我的问题是这个ID.在我的脑海里,我将文件传递给服务器,服务器应该负责存储该文件并生成一个唯一的ID以便以后检索它,然后将此ID返回给具有ok状态的客户端.
所以我正在考虑这样做,将它发送到服务器/资源,没有ID,但这样做还是设计不好?
我有一个带有指令的 Web 应用程序,其中模板 url 是通过工厂构建的,但有时我还需要其中一个属性的值,所以我执行以下操作:
myDirective.$inject = ['myFactory'];
function myDirective(myFactory) {
return {
restrict: 'E',
replace: true,
scope: {},
bindToController: {
...
},
controller: myDirectiveController,
templateUrl: function(elem, attrs) {
return angular.isDefined(attrs.myval) ? myFactory.url() : myFactory.altUrl();
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我将其中的一些更改为组件,但我没有设法做同样的事情,因为现在组件是对象而不是函数。
我可以不使用 attrs,就像这样
angular.component('myDirective', {
bindings: {
...
},
controller: 'myDirectiveController as vm',
templateUrl: function(myFactory) {
return myFactory.url();
}
}
Run Code Online (Sandbox Code Playgroud)
但如果我也尝试使用 attrs
angular.component('myDirective', {
bindings: {
...
},
controller: 'myDirectiveController as vm',
templateUrl: function(elem, attrs, myFactory) {
return angular.isDefined(attrs.myval) ? myFactory.url() : …Run Code Online (Sandbox Code Playgroud) 所以我试图在我的Ionic 2应用程序中使用自定义字体,由于某种原因,它显示的内容不正确.
我的字体是GothamRounded,所以我将所有.ttf,.svg,.otf和.eot文件复制到我的Ionic项目的www/fonts文件夹中.
然后,在app.component.scss(我的主要组件)里面我写了这个:
app {
@font-face {
font-family: GothamRounded;
src: url($font-path + "/GothamRounded-Book.ttf");
}
font-family: GothamRounded;
}
Run Code Online (Sandbox Code Playgroud)
现在,当我的应用程序重新加载时,我的字体已经改变,如果我检查一个带有文本的元素,我可以在开发控制台中看到:
app {
font-family: GothamRounded;
}
Run Code Online (Sandbox Code Playgroud)
但显示的文字有一个seriff,我的字体没有,所以我猜这实际上并没有得到真正的字体.
知道可能会发生什么吗?谢谢
我在 Angular 应用程序的 app.module 中使用函数工厂来初始化一项服务。像这样的东西
export function analyticsServiceFactory() {
return ConfigService.env === "development" ? new AnalyticsDevService() : new AnalyticsService();
}
...
const providers = [
...
{ provide: AnalyticsService, useFactory: analyticsServiceFactory }
];
Run Code Online (Sandbox Code Playgroud)
到目前为止,这一切都运行良好。问题来了,因为现在我需要将状态(@ngrx)作为这些服务之一的依赖项注入。我该怎么做呢?
我知道我可以向工厂提供程序添加依赖项,但如何添加状态?这可能吗?
此外,我的商店和我的analyticsServiceFactory是在不同的模块中定义的,这使得它变得更加困难。
有任何想法吗?谢谢。