如何在ng-if指令中表达条件?
现在我试过这个
<div ng-if="{ selectedTab == 'decoupage'}">
...
Syntax Error: Token '==' is unexpected, expecting [:] at column 15 of the expression [{ selectedTab == 'decoupage'}] starting at [== 'decoupage'}].
Run Code Online (Sandbox Code Playgroud)
我正在使用Angular 1.2.0.
我有一个问题是让swagger doc生成工作.
这是我使用的maven deps:
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
<version>2.17</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-jersey2-jaxrs_2.10</artifactId>
<version>1.3.12</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我在ResourceConfig类中添加了swagger ressources:
@ApplicationPath("REST")
public class RESTServlet extends ResourceConfig {
public RESTServlet() {
// ...
// Swagger
register(ApiListingResourceJSON.class);
register(JerseyApiDeclarationProvider.class);
register(JerseyResourceListingProvider.class);
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
然后我声明了一个servlet来配置Swagger:
@WebServlet(name = "SwaggerJaxrsConfig", loadOnStartup = 2)
public class SwaggerJaxrsConfig extends HttpServlet {
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
BeanConfig beanConfig = new BeanConfig();
beanConfig.setVersion("1.0.2");
beanConfig.setResourcePackage("some.foo.package"); …Run Code Online (Sandbox Code Playgroud) 我有一个指令,在某些权限检查时删除了一个dom元素:
angular.module('app').directive('permissionNeeded', function ($location, $route, SecurityService) {
return {
restrict: 'A',
link: function (scope, element, attributes) {
var permissionNeeded = attributes.permissionNeeded;
if (permissionNeeded) {
if (SecurityService.checkAccess($route.current.name) !== permissionNeeded) {
element.remove();
}
}
}
};
});
Run Code Online (Sandbox Code Playgroud)
指令工作正常,但我无法测试.在我期望的断言之后,DOM操作(element.remove())似乎被触发:
it('should not do anything cos permissions are correct', function () {
$route.current = {
name: 'import'
}
var element = compileTemplate('<span permission-needed="W">Some content goes here</span>');
$rootScope.$digest();
expect(element.html()).toBe(''); // FAIL!!! it's still equals to 'Some Content goes here'
});
Run Code Online (Sandbox Code Playgroud)
我已经看到了关于使用$ timeout函数延迟期望断言的一些答案,但无论我尝试过什么断言失败(element.html()仍然等于'某些内容在这里')
然而,有趣的是(是吗?)如果我只是改变dom而不是在我的指令中删除它,我的测试就可以了:
angular.module('app').directive('permissionNeeded', function ($location, …Run Code Online (Sandbox Code Playgroud) 我希望我的开放图层地图适合整个屏幕.我希望用户能够在里面导航,缩放和拖动它.
这是一个小提琴:http://jsfiddle.net/mhicauber/t8K4p/1/
我的问题是我不明白我在制作地图时给出的一些价值观:
mapLayer = new OpenLayers.Layer.Image(
'My map',
'http://tchanca.com/private/Masse1080.jpg',
OpenLayers.Bounds.fromString("-160,-90.0,160,90.0"), new OpenLayers.Size(screenSize.width, screenSize.height), {
maxExtent: OpenLayers.Bounds.fromString("-160,-90.0,160,90.0")
});
Run Code Online (Sandbox Code Playgroud)
使用这些值,用户可以将地图的一部分拖出屏幕.如果我将maxExtent值更改为0,0,0,0,那么,map将包含在屏幕中,并且不能拖到外面但是只要我放大,我就无法拖动地图.
有什么-160,-90.0,160,90.0价值可以参考?我应该用什么代码:
非常感谢你.请原谅我对制图学缺乏了解,我对这个问题很不错...