ui.router状态未按预期工作

时间:2017-01-30 11:48:44

标签: angularjs angular-ui-router-extras

我正在使用public static void NaiveBayes(String training_file, String testing_file) throws FileNotFoundException, IOException, Exception{ //filter StringToWordVector filter = new StringToWordVector(); Classifier naive = new NaiveBayes(); //training data Instances train = new Instances(new BufferedReader(new FileReader(training_file))); int lastIndex = train.numAttributes() - 1; train.setClassIndex(lastIndex); filter.setInputFormat(train); train = Filter.useFilter(train, filter); //testing data Instances test = new Instances(new BufferedReader(new FileReader(testing_file))); test.setClassIndex(lastIndex); filter.setInputFormat(test); Instances test2 = Filter.useFilter(test, filter); naive.buildClassifier(train); for(int i=0; i<test2.numInstances(); i++) { System.out.println(test.instance(i)); double index = naive.classifyInstance(test2.instance(i)); String className = train.attribute(0).value((int)index); System.out.println(className); } } 来检测Angular App中的状态更改。但控制器没有被加载调用。

以下是我的ui.router代码。

app.js
当我的州为 var admin = angular.module('admin',['admin.core']); angular.module('admin.core', ['ui.router', 'satellizer', 'ngMaterial']); admin.config(function($mdThemingProvider, $stateProvider, $urlRouterProvider, $authProvider, $locationProvider){ $mdThemingProvider.theme('default').primaryPalette('light-blue', { 'default': '700', 'hue-1' : 'A200', }).accentPalette('blue'); // Satellizer configuration that specifies which API route the JWT should be retrieved from $authProvider.loginUrl = '/api/authenticate'; // Redirect to the auth state if any other states are requested other than users $urlRouterProvider.otherwise('/admin/login'); console.log($stateProvider) $stateProvider .state('login', { url: '/admin/login', name: 'login', controller: 'AuthController as auth', }) .state('users', { url: '/admin/users', controller: 'UserController as user' }); $locationProvider.html5Mode(true); }); admin.controller('AuthController', AuthController); function AuthController($auth, $state, $scope) { console.log("Called"); var vm = this; vm.login = function() { var credentials = { email: vm.email, password: vm.password } console.log(credentials); // Use Satellizer's $auth service to login $auth.login(credentials).then(function(data) { // If login is successful, redirect to the users state $state.go('users', {}); }); } } 时,

AuthController未被调用。

1 个答案:

答案 0 :(得分:1)

使用strcpy(userString, newSentence); 时,您必须提供基本href位置。它会将您的州解析网址解析为$locationProvider.html5Mode(true);,并应解决您的问题。

尝试将http://localhost:8001/admin/#/login添加到主索引文件的<base href="/" />部分,以指定应用程序的基本路径。

https://docs.angularjs.org/api/ng/provider/$locationProvider

还在您的服务器上提供<head />文件,以便将特定请求重定向到邮件索引页面。您可能必须调整一下以适应您的结构。

.htaccess
  

请注意,必须在我的apache服务器上启用mod_rewrite。通过   默认情况下已禁用。