是否可以将控制器注入另一个属于同一模块的控制器?
例:
var app = angular.module('myAppModule', [])
.controller('controllerOne', ['$scope', function($scope){
$scope.helloWorld = function(){
return 'Hello World';
}
}])
.controller('controllerTwo', ['$scope', 'controllerOne', function($scope, controllerOne){
console.log(controllerOne.helloWorld());
}])
Run Code Online (Sandbox Code Playgroud)
我一直在controllerOne上得到未知的提供者.我不知道它是如何可能的,因为它们在同一个模块中共存.任何帮助将非常感激.
javascript dependency-injection angularjs angularjs-scope angularjs-controller
我正在为Web应用程序实施Protractor测试.我已经做了一些谷歌搜索,但我已经提出了zip,我希望我创建的每个规范关闭浏览器后,它在该特定的spec文件中运行所有测试,然后继续到下一个-spec文件,我有使用"beforeAll"和"afterAll"之类的东西,但Jasmine不承认这些方法.正确方向上的一点会很棒!
describe('我将在后面写一些更有意义的东西:)',function(){
//not sure if this method actually exist in Jasmine
afterAll(function () {
//restart browser or something of the nature
});
it('should do stuff', function () {
});
it('do stuff', function () {
});
Run Code Online (Sandbox Code Playgroud)
});
然后浏览器应该关闭,然后打开备份以运行下一个规范.
我有一个 Spring Boot 服务,我正在尝试使用 Micrometer Tracing 来实现跟踪。我假设我所要做的就是在我的 pom.xml 中包含以下内容,它就会起作用:
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
添加上面的内容没有任何作用。我也有弹簧致动器。我尝试过添加,micrometer-tracing-bridge-brave
但那是行不通的。使用 Spring Cloud Slueth 和所有内容都可以使用自动配置,我读过一些文章,其中指出 Micrometer 跟踪可以与 Spring MVC 一起使用,无需额外配置。我的问题是如何配置 Micrometer Tracing 与 Spring Webflux 一起使用?或者 Spring Webflux 还不支持?
提前致谢!!
更新:
我还在static void main
方法中尝试了以下操作:
Hooks.enableAutomaticContextPropagation();
Run Code Online (Sandbox Code Playgroud)
这也行不通。如果有人使用千分尺进行追踪,那么一个例子就太棒了!
当我格式化HTML文件时,VS Code正在堆叠元素属性。有什么办法可以禁用此功能?
我有一个在 Docker 容器中运行的 Spring Boot 服务。我正在使用 HttpServletRequest 从传入的客户端请求中获取远程 IP 地址。这在本地按预期工作,但是一旦服务在 Docker 容器中运行,获取的 IP 就是 Docker 容器 IP,而不是客户端 IP。有没有办法解决这个问题并获取实际的客户端IP?非常感激任何的帮助。
以下是更多编程细节:
@GetMapping("/foo)
public ResponseEntity requestBar(HttpServletRequest request) {
String clientIp = request.getRemoteAddr();
//DO STUFF WITH IP
}
Run Code Online (Sandbox Code Playgroud)
上面是“bar”的 GET 请求示例。使用 HttpServletRequest 您可以获得发出请求的机器的远程地址。在本地运行(在非 Docker 化的本地计算机上)上面的效果非常好。服务获取客户端IP,我可以验证IP是否正确。在 Docker 中托管相同的服务,调用 getRemoteAddr() 将为容器提供默认网关 IP。我希望这个进一步的解释能让我更清楚地了解我想要完成的任务。一如既往,我们将非常感谢任何和所有的帮助。
更新:澄清一些花絮,Spring Boot(v1.5.13)服务在 Docker 主机(Docker 版本 18.06.1-ce,构建 e68fc7a)上运行。我所说的本地运行是指在开发过程中在本地计算机上启动服务时。我使用最新版本的 Intellij 来完成所有 Java 开发工作。该服务可以在我的开发机器上使用 Intellij 启动。
我试图弄清楚如何在使用 RouterFunctions 时将查询参数添加到路由。这是我到目前为止所拥有的:
@Bean
public RouterFunction<ServerResponse> routes() {
return
RouterFunctions.route()
.GET("/one/{one}", routeHandlerOne::handlerOne)
.GET("/two", routeHandlerOne::handlerTwo)
.build();
}
Run Code Online (Sandbox Code Playgroud)
对于路线,two
我想添加一个查询参数,例如/two?three
. 任何帮助都会非常有帮助,谢谢!
我已经使用 Ionic v5 w/React 创建了一个测试应用程序,但我在文档中没有看到有关如何配置 Sass 预处理的任何细节。我在项目结构中有几个 sass 文件,但它们似乎没有被加载或被处理。我在 package.json 中添加了 node-sass。任何帮助将非常感激。我使用 Ionic Cli 创建了一个空白应用程序并将一些 .scss 文件添加到项目目录中。
我对Angular的材料设计很新,我发现很难为初学者找到合适的教程.我想知道是否可以使用$ mdThemingProvider预定义的调色板(css)?是否有任何适当的文档可以向我解释$ mdThemingProvider实际上是代码明智的.任何帮助将非常感激!
我对 React 和 Ionic 还很陌生。我试图完成的是创建一条“受保护的路线”。我创建一个简单的上下文,名为AuthContext
:
import { createContext, Dispatch } from 'react';
/**
* Context interface for AuthAuthentication/Authorization
*
* @property isAuthenticated
* @property dispatch
*
* @interface
*/
interface AuthDefaultContext {
isAuthenticated: boolean;
dispatch: Dispatch<any>
}
/**
* Authentication/Authorization context for managing
* authenticating/ed and authorizing/ed users
*/
export const AuthContext = createContext<AuthDefaultContext>({
isAuthenticated: false,
dispatch: () => {}
});
Run Code Online (Sandbox Code Playgroud)
和FunctionalComponent称为ProtectedRoute
:
interface ProtectedRouteProps {
ProtectedComponent: FunctionComponent,
routePath: string
}
export const ProtectedRoute: FunctionComponent<ProtectedRouteProps> = ({ …
Run Code Online (Sandbox Code Playgroud) 我回来了更多的量角器Q&A.所以,我在尝试查找幻灯片菜单中的元素时遇到了一个问题.
html片段:
<div class="ng-scope" ui-view="navmenu">
<nav class="menu slide-menu-left ng-scope">
<md-content class="md-default-theme" style="display: table" ng-click="slideMenuLeft()" tabindex="0">
<button class="md-button md-default-theme" ng-transclude=""
style="width:50%;height:72px;border-right:1px solid #ddd;border-bottom:1px solid #ddd"
ng-click="checkmap()" tabindex="0">
Run Code Online (Sandbox Code Playgroud)
以下是我尝试从此菜单中获取按钮的方法:
element(by.css('Button[ng-click="logoff()"]'));
element(by.xpath('/html/body/section/div[@class="ng-scope"]/nav[@class="menu slide-menu-left ng-scope"]/md-content/button[@ng-click="logoff()"]'));
Run Code Online (Sandbox Code Playgroud)
量角器不喜欢并继续告诉我这个:
Stacktrace:
ElementNotVisibleError: element not visible
(Session info: chrome=40.0.2214.115)
(Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Windows NT 6.3 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 31 milliseconds
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
Run Code Online (Sandbox Code Playgroud)
任何人都可以向我提出我可能做错的建议吗?
我试图弄清楚如何确定特定星期一是某个月的第一个,第二个,第三个还是第四个星期一.我已经弄清楚如何获得使用LocalDate类的下一个星期一和月份的周.
LocalDate now = LocalDate.of(2018, 2, 1);
LocalDate nextMonday = now.with(next(DayOfWeek.MONDAY));
WeekFields weekFields = WeekFields.of(Locale.getDefault());
int week = nextMonday.get(weekFields.weekOfMonth());
Run Code Online (Sandbox Code Playgroud)
在上面的示例中,代码获取下一个星期一及其所在的星期.星期是2月的第二周,但是星期一不是第二个星期一,它是第一个星期一.任何有关这方面的帮助将不胜感激.
我正试图'protractor.Key.DELETE'
让量角器按下删除键.关于如何做到这一点的任何想法?以下内容对我不起作用:
browser.actions().keyDown(protractor.Key.DELETE).sendKeys().perform();
Run Code Online (Sandbox Code Playgroud)
量角器给我以下错误信息:
失败:不是修饰键
我在将整数日期 (20180525) 转换为 YYYY-MM-DD 格式的日期时遇到问题。有没有办法做到这一点,还是我应该只将其转换为代码(在这种情况下为 Java)?对此的任何帮助将不胜感激。谢谢!
angularjs ×4
javascript ×4
protractor ×3
spring-boot ×3
reactjs ×2
dayofweek ×1
docker ×1
end-to-end ×1
ionic5 ×1
java ×1
java-8 ×1
java-time ×1
localdate ×1
postgresql ×1
sass ×1
spring ×1
testing ×1
trace ×1