我在Ruby on Rails中使用AngularJS进行应用程序。 我的application.js文件UI-view not changed
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require angular.min
//= require angular-ui-router.min
var app = angular.module("railsApp", ['ui.router']).config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('home', {
url: '/',
templateUrl: 'home.html'
})
.state('about', {
url: 'about',
templateUrl: 'about.html'
});
$urlRouterProvider.otherwise('/');
});
app.controller("mainCtrl", function($scope) {
$scope.helloMsg = "Hello from test application";
});
索引页
<h1>Welcome#index</h1>
<p>Find me in app/views/welcome/index.html.erb</p>
{{helloMsg}}<br>
<ui-view></ui-view>
<a ui-sref="about">about</a>
当索引页面加载我看到消息“你好,从测试应用程序”,进入<ui-view></ui-view>
取代模板的内容,但我点击有关链接新模板未加载并且url未更改为/ about。问题是什么?感谢和抱歉我的英文
唉唉......按秒打我:) – sameera207
非常感谢你,你的建议有助于纠正问题! – motoroller
正确的配置是'var app = angular.module(“railsApp”,['ui.router']).config($ stateProvider $ urlRouterProvider){stateProvider .state('home',{ url : '/', templateUrl: 'home.html做为' }) .STATE( '约',{ URL: '/约', templateUrl: 'about.html' }); $ urlRouterProvider.otherwise ('/'); }); app.controller(“mainCtrl”,function($ scope){ $ scope.helloMsg =“Hello from test application”; });' – motoroller