由于我的声誉不够,所以我无法附上图片。在这里,我将附上我的演示代码。 3.1:index.html
var app = angular.module("demo", ['ui.router']);
app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
//$urlRouterProvider.otherwise("/landing/dashboard");
$urlRouterProvider.otherwise("/login");
//$urlRouterProvider.when('/landing/influencers', '/landing/influencers/dashboard/market-view');
$stateProvider
.state('home', {
url: '/home',
templateUrl: 'view/home.html',
controller: function(){
alert("123");
}
})
.state('login', {
url: '/login',
templateUrl: 'view/login.html'
});
}]);
app.run(['$state', function ($state) {
alert("running...");
/*$state.transitionTo('home');*/
$state.go('home');
}]);
3.2:appDemo.js
app.controller('demoController', function($scope, $state, demoService){
$scope.goToHomePage = function(){
alert('AAA');
$state.go("home");
}
});
3.3:DemoController.js
List
当我点击“转到主页”按钮时,没有任何反应,但提示在goToHomePage函数中设置了“AAA”消息。
知道如何正确转发到主页吗?
任何建议都应该受到高度赞赏。
答案 0 :(得分:1)
您的版本angular-ui-roter
太旧,与1.0.3
不兼容。
将角度脚本版本从1.3.15
更新为public class Server {
static final int PORT = 8005;
static final int QUEUE = 50;
public Server() {
while (true) {
try (ServerSocket serverSocket = new ServerSocket(PORT, QUEUE);
Socket socket = serverSocket.accept();
DataInputStream input = new DataInputStream(socket.getInputStream());
DataOutputStream output = new DataOutputStream(socket.getOutputStream())) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
output.writeUTF("Hey, this is the server!");
output.flush();
System.out.println(input.readUTF());
} catch (IOException e) {
System.out.println();
e.printStackTrace();
}
}
});
thread.start();
} catch (IOException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
public static void main(String[] args) {
new Server();
}
}
将解决您的问题。