我有一个用AngularDart编写的Chrome打包应用程序,并尝试获取一些外部图标以使应用程序看起来更好,但无法通过网络找到任何示例.尝试了很多东西以及下面的解决方法,但无法使其正常工作.我将@ font-face添加到我的css中,如下所示:
@font-face {
font-family: 'Icons';
src: url(data:font/ttf;charset=utf-8;base64,<ttf file encoded to base64>) format('truetype'),
url(data:font/woff;charset=utf-8;base64,<woff file encoded to base64>) format('woff'),
url(data:font/svg;charset=utf-8;base64,<svg file encoded to base64>) format('svg');
font-weight: normal;
font-style: normal;
}
[class^="icon-"], [class*=" icon-"] {
font-family: 'Icons';
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-uniF085:before {
content: "\f085";
}
Run Code Online (Sandbox Code Playgroud)
我试图通过将我的图标文件:.ttf,.woff,.svg,.eot转换为base64并将它们嵌入到我的控制器CSS中来避免CSP(内容安全策略)问题但是当我运行应用程序时我在铬中看到的全部内容是默认的方框而不是我引用的图标(); 控制台或Chrome浏览器上没有错误.我想知道是否有人使用Chrome打包应用程序使用自定义或外部图标/字体.如果有任何解决方法,请告诉我.
在AngularDart中的所有弃用之后,现在通过我的模块构造函数中的下面的initRoutes方法配置路由.
//inside the main of the appliction
..
this.bind(RouteInitializerFn, toValue:initRoutes);
this.bind(NgRoutingUsePushState, toFactory:(_) => new NgRoutingUsePushState.value(false));
//in routeconfig.dart file which is imported in the main.dart
void initRoutes(Router router, RouteViewFactory viewFactory) {
viewFactory.configure({
'loginPage': ngRoute(
path: '/loginPage',
view: 'view/loginPage.html'),
'landingPage': ngRoute(
path: '/landingPage',
view: 'view/landingPage.html',
defaultRoute: true,
enter: _checkAuthentication
...
Run Code Online (Sandbox Code Playgroud)
我的问题是如何在routeconfig.dart中注入具有_checkAuthentication方法的Service类?既然它不是一个类,怎么能在这里获得依赖注入?或者是否有另一种方法在Module contructor中初始化和注册RouteInitializerFn?