【发布时间】:2014-01-30 23:28:08
【问题描述】:
所以,我正在尝试设置我的第一个 Angular 应用程序,问题是通过 ajax 检索的模板没有被 Angular 插值。我正在使用 Ruby Sinatra 框架进行简单的 HTTP,这里是主要部分代码: index.html
<div ng-view></div>
main.js
var app = angular.module('myApp', ['ngRoute']);
app.config(function($routeProvider) {
$routeProvider.when('/', {
templateUrl: 'templates/home.html',
controller: 'HomeController'
})
})
app.controller('HomeController', function($scope) {
});
home.html
{{ 1 + 1 }}
Sinatra 应用程序.rb
#!/usr/bin/env ruby
require 'sinatra'
class HelloWorldApp < Sinatra::Base
get '/' do
send_file 'index.html'
end
get '/js/:name' do
send_file "js/#{params[:name]}"
end
get '/templates/:name' do
send_file "templates/#{params[:name]}"
end
end
现在,当我加载 http://localhost:9292/ 时,我得到的是 {{ 1 + 1 }} 而不是 2。有什么问题?
【问题讨论】:
标签: javascript ajax angularjs sinatra