我使用 Angular 8。
这个问题仅适用于 Angular DI 专家。
首先,我制作了一个 Angular 库,将在许多项目中重用。
在这个库中,我创建了一个抽象服务,必须在使用它的项目中定义该服务。
我在我的库中定义了一个名为 BridgeService 的抽象类
在我的主项目中,我创建了 BridgeService 来实现它:(在接下来的几行中,我将向您展示抽象的 BridgeService)
主要项目 > BridgeService :
import { BridgeService as AbstractBridgeService } from 'myLibrary';
@Injectable()
export class BridgeService implements AbstractBridgeService {
hello(){
alert('hello Word');
}
}
Run Code Online (Sandbox Code Playgroud)
主项目>用户模块:
import { UsersModule as LibraryUsersModule } from 'myLibrary';
@NgModule({
imports: [
CommonModule,
LibraryUsersModule,
],
//...
providers: [
BridgeService
// some try:
//{ provide: BridgeService, useClass: BridgeService }
],
})
export class UsersModule {
constructor(private bridgeService: BridgeService){
this.bridgeService.hello(); …Run Code Online (Sandbox Code Playgroud) angular angular-dependency-injection angular7 angular8 angular9
我在使用Bootstrap 4开发并尝试创建Font Awesome按钮时发现的一个主要问题是,当我创建一系列按钮时,我得到了不同大小的按钮,唯一获得相同大小按钮的方法是为每个按钮使用相同字体一个问题是由于Font Awesome的字体大小并不相同。
<a class="btn btn-outline-warning" type="button" href="#">
<i class="fa fa-edit"></i>
</a>
<a class="btn btn-outline-danger" type="button" href="#">
<i class="fa fa-trash"></i>
</a>
Run Code Online (Sandbox Code Playgroud)
有没有实际的例子可以解决这个问题?
Symfony 3.0:
在我的项目中,我有许多包含超过 50 个字段的实体,因此对于显示每个实体的树枝,我决定通过一个简单的循环自动显示 50 个字段。
第一个问题:如何获取实体的所有字段名称,我通过创建自定义树枝过滤器解决了这个问题:
<?php
// src/HomeBundle/Twig/HomeExtension.php
namespace HomeBundle\Twig;
class HomeExtension extends \Twig_Extension
{
public function getFilters()
{
return array(
new \Twig_SimpleFilter('object_keys', array($this, 'getObjectKeys')),
);
}
public function getObjectKeys($object)
{
//Instantiate the reflection object
$reflector = new \ReflectionClass( get_class($object) );
//Now get all the properties from class A in to $properties array
$properties = $reflector->getProperties();
$result=array();
foreach ($properties as $property)
$result[] = $property->getName();
return $result;
}
public function getName()
{
return 'app_extension';
}
}
?>
Run Code Online (Sandbox Code Playgroud)
现在产生错误的第二个问题:如何在循环中访问对象属性: …
我正在我的机器Ubuntu 16上进行Symfony 3项目,我还没有安装XAMPP或LAMP,我启动了
php bin/console server:start
[OK] Server listening on http://127.0.0.1:8000
Run Code Online (Sandbox Code Playgroud)
所以对localhost:8000的HTTP请求正确响应,但我问这是否意味着自动在我的机器上安装了apache?
我看到很多替代方法来检查是否安装了apache,这是系统响应:
apache2 -v
The program 'apache2' is currently not installed. You can install it by typing:
sudo apt install apache2-bin
Run Code Online (Sandbox Code Playgroud)
dpkg --get-selections | grep apache
libapache-pom-java install
Run Code Online (Sandbox Code Playgroud)
apt-cache policy apache2
apache2:
Installed: (none)
Candidate: 2.4.18-2ubuntu3.5
Version table:
Run Code Online (Sandbox Code Playgroud)
//check who is listening on localhost:8000
lsof -i :8000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
php7.0 5443 karimengineer 11u IPv4 89313 0t0 TCP localhost:8000 …Run Code Online (Sandbox Code Playgroud) symfony ×2
angular ×1
angular-dependency-injection ×1
angular7 ×1
angular8 ×1
angular9 ×1
apache ×1
apache2 ×1
attributes ×1
bootstrap-4 ×1
css ×1
font-awesome ×1
http ×1
object ×1
php ×1
twig ×1
variables ×1