小编Soh*_*ani的帖子

使用ng-view时,AngularJS document.ready不起作用

在我的应用程序中的多个路线之间导航时,我在angularJS中遇到了document.ready的问题.它只适用于我使用ctrl + f5(页面重新加载); 它似乎在页面之间导航不会改变文档的状态以备就绪.

调节器

  angular.element(document).ready(function() {
    window.scrollTo(0,90);
});
Run Code Online (Sandbox Code Playgroud)

主要的html文件

<!DOCTYPE html >
<html ng-app="myApp">
    <head>
        <meta http-equiv="content-type" content="text/html;charset=utf-8" />
        <title></title>
    </head>
    <body>
        <div class="container">
            <div ng-view></div>
        </div>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

应用文件

var mainModule = angular.module('myApp', ['ui.bootstrap.dialog']);
function viewServiceConfig($routeProvider) {
$routeProvider.
    when('/', {
        controller: SomeController,
        templateUrl: 'somehtml.html'
    }).



    when('/someroute', {
        controller: SomeRouteController,
        templateUrl: 'someroutehtml.html'
    }).


    otherwise({
        redirectTo: '/'
    });
}

mainModule.config(viewServiceConfig);
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

21
推荐指数
2
解决办法
3万
查看次数

Spring安全自定义身份验证提供程序始终导致错

我正在Spring安全性中实现一个自定义身份验证提供程序来验证用户.身份验证服务器位于远程端(Restful service).我每次打电话给我的服务时都会遇到这个错误(这段代码到达了

return new UsernamePasswordAuthenticationToken(userDetails, authentication.getCredentials().toString(), grantedAuthorities); 部分)

{"error":"invalid_client","error_description":"Bad client credentials"}
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

CustomAuthenticationProvider

public class CustomAuthenticationProvider implements AuthenticationProvider {


@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {

    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(HttpClients.createDefault());
    RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(60 * 1000)
            .setSocketTimeout(60 * 1000).build();
    PoolingHttpClientConnectionManager poolingHttpClientConnectionManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
    poolingHttpClientConnectionManager.setMaxTotal(20);
    poolingHttpClientConnectionManager.setDefaultMaxPerRoute(20);
    CloseableHttpClient httpClientBuilder = HttpClientBuilder.create()
            .setConnectionManager(poolingHttpClientConnectionManager).setDefaultRequestConfig(requestConfig)
            .build();
    requestFactory.setHttpClient(httpClientBuilder);
    RestTemplate restTemplate = new RestTemplate(requestFactory);

    UserInfoRequestBean userInfoRequestBean = new UserInfoRequestBean();

    String username = (String)authentication.getPrincipal();
    userInfoRequestBean.setUsername(username);
    userInfoRequestBean.setPassword((String)authentication.getCredentials());

    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);

    HttpEntity<?> httpEntity = …
Run Code Online (Sandbox Code Playgroud)

java authentication spring restful-authentication spring-security

5
推荐指数
1
解决办法
868
查看次数

AngularJS在module.config中更改URL

Restangular在我的angularjs App中使用setErrorInterceptor并用于在一个地方处理响应错误.如果发生错误,我想将用户重定向到登录页面.我知道唯一的providers&constants可注射配置阶段.

var app = angular.module('ourstandApp', ['ngRoute', 'restangular', 'ui.bootstrap', 'ngCookies', 'angularFileUpload']);
    // Global configuration

    app.config(function (RestangularProvider, baseRequestConfig, $routeProvider, urlsProvider) {
        var getBaseRequestUrl = function () {
            return baseRequestConfig.protocol + "://" + baseRequestConfig.hostName + ":" + baseRequestConfig.portNumber + baseRequestConfig.resourcePath;
    }
        var initializeRoute = function () {
            $routeProvider.when('/', {
                controller: LoginController,
                templateUrl: 'views/login.html'
            }).
            otherwise({
                redirectTo: '/'
            });
        }

        initializeRoute();
        RestangularProvider.setBaseUrl(getBaseRequestUrl());
        RestangularProvider.setErrorInterceptor(function (resp) {
            goToLogin();  //  i want to change url to login page …
Run Code Online (Sandbox Code Playgroud)

angularjs angular-routing restangular

3
推荐指数
1
解决办法
7500
查看次数

为AngularJS中的select选项添加ng-dbclick

我有一个<select>标签,用于ng-options绑定选项select.我的问题是如何添加ng-dbclick到每个选项select

这是我的代码

<select  size="4"  ng-model="pattern" ng-options="p.name  for p in patterns | filter:obj">

</select>
Run Code Online (Sandbox Code Playgroud)

html-select angularjs

2
推荐指数
1
解决办法
2596
查看次数

在整个应用程序中更改SystemTray颜色 - Windows Phone

我想SystemTray在整个应用程序中更改背景和前景颜色,但我没有定义基页,现在我无法更改每个页面的颜色.有没有办法改变SystemTray整个应用程序的背景和前景色App.xaml.cs

system-tray windows-phone windows-phone-8

0
推荐指数
1
解决办法
399
查看次数