使用angular2中的锚标记的同一页面路由

时间:2017-03-18 11:31:50

标签: angular angular2-routing swagger-ui

我在angular2应用程序中实现了swagger-ui(swagger-ui.js)。当它被渲染并且我点击任何链接(#!users / get_user)时,它会路由到链接而不是滚动到该div。

window['swaggerUi'] = new window['SwaggerUi']({
                spec: this.swaggerJson,
                dom_id: "swagger-ui-container",
                supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
                useJQuery: true,
                onComplete: function () {
                    }
                    window['jQuery']('pre code').each(function (i, e) {
                        window['hljs'].highlightBlock(e)
                    });
                },
                onFailure: function (data) {
                    console.log("Unable to Load SwaggerUI");
                },
                docExpansion: "none",
                sorter: "alpha"
            });

包含href的链接是路由,但包含data-id的链接正常工作。 如何阻止这些链接的路由。

 <a href="#!/users/get_users_userid" class="toggleOperation">Users</a> 
 <!-- routes to that url(localhost:8080/#!/users/get_users_userid) -->

 <a href="#" class="expandResource" data-id="users">Expand Operations</a> 
 <!-- it expands the div -->

1 个答案:

答案 0 :(得分:0)

我修好了。我改变了swagger-ui.js。

我将href更改为href =“”,以查看在点击时导致路由的元素。

这是一种解决方法,但它现在有效。 :)

相关问题