Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ajax AngularJS与Wordpress路线问题_Ajax_Wordpress_Angularjs_Routing - Fatal编程技术网

Ajax AngularJS与Wordpress路线问题

Ajax AngularJS与Wordpress路线问题,ajax,wordpress,angularjs,routing,Ajax,Wordpress,Angularjs,Routing,我和AngularJS一起玩了几个星期,感觉我对水疗有了更多的了解。鉴于Angular是前端,需要第三方数据源才能从数据库中获取数据,我已经使用了WP JSON插件,现在正试图在我的Wordpress站点上使用它 到目前为止,我已经完成了这项工作,获取帖子并将其放入模板中: $http.get('http://site:8888/wp-json/posts') .success(function(data, status, headers, config){ $scope.items = d

我和AngularJS一起玩了几个星期,感觉我对水疗有了更多的了解。鉴于Angular是前端,需要第三方数据源才能从数据库中获取数据,我已经使用了WP JSON插件,现在正试图在我的Wordpress站点上使用它

到目前为止,我已经完成了这项工作,获取帖子并将其放入模板中:

$http.get('http://site:8888/wp-json/posts')
.success(function(data, status, headers, config){
  $scope.items = data;
})
很好,很好用。现在,我想将我的帖子链接到一个单独的帖子页面,我完全无法确定我的templateUrl要使用什么(如果需要的话):


这里的冲突是WP已经提供了路由。但我几乎需要避开它,这样我就可以让AngularJS为我完成AJAX加载。有什么想法吗?

有了SPA,你根本不需要wordpress路由。Wordpress将只是您前端的数据提供者。你的问题其实不是关于使用wordpress和angular,而是“如何使用ngRoute?”

angulars开发者指南中有一个关于路由如何工作的好例子:$route


回答您的问题:
templateUrl
是指向包含帖子模板的Html文件的路径。Angular Lazy使用
$templateCache
加载该文件并对其求值。因此,您可以在那里初始化一个控制器,从wordpress等获取数据。

谢谢Julian,我一直在兜圈子,但我认为您刚才的措辞更清晰了。所以我需要做的是创建我自己的single.html页面,并查找与我的内容匹配的URL参数。
.config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider){
  $routeProvider
  .when('/:category/:post', {
    templateUrl: ?????
  });
}])