Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/364.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
Javascript 角度ui路由器$位置_Javascript_Php_Angularjs_Wordpress - Fatal编程技术网

Javascript 角度ui路由器$位置

Javascript 角度ui路由器$位置,javascript,php,angularjs,wordpress,Javascript,Php,Angularjs,Wordpress,我试图在wordpress单页模板上实现Angular ui路由器。这是我的app.js: angular .module('app', [ 'ui.router' ]) .config(['$urlRouterProvider', '$stateProvider', function($urlRouterProvider, $stateProvider){ $urlRouterProvider.otherwise('/'); $stateProvider

我试图在wordpress单页模板上实现Angular ui路由器。这是我的app.js:

angular
    .module('app', [
    'ui.router'
])

.config(['$urlRouterProvider', '$stateProvider', function($urlRouterProvider, $stateProvider){
    $urlRouterProvider.otherwise('/');

    $stateProvider
        .state ('home', {
            url: '/',
            templateUrl: '../../wp-content/themes/my_theme/templates/home.html'
        })
        .state ('about', {
            url: '/about',
            templateUrl: '../../wp-content/themes/my_theme/templates/about.html'
        })
}])
现在我的问题是:如何用Angular
$location.path()
函数替换
templateUrl
,以使脚本更稳定

是的


我会使用
get_template_directory_uri()
在your functions.php中将位置传递给应用程序。

$location.path()
用于angular的路由,而不是模板URL。那不是一回事,所以我想这是错误的选择?是否有其他方法将我的wordpress模板目录实现到这个javascript中?是否存在
templateUrl
不稳定的问题?你能详细解释一下为什么它在你的实现中会不稳定吗?我倾向于在每次重装时上传带有持续数字的wordpress主题,因为否则它在wordpress缓存中的剩余文件会有一些问题。到目前为止,这还不是一个问题,因为我所有的模板URL都是灵活的,如果可能的话,我希望保持这种方式。