AngularJS,UI路由器和放大器;火力地堡应用在Plunker不工作 [英] AngularJS, ui-router & Firebase app not working in Plunker

查看:114
本文介绍了AngularJS,UI路由器和放大器;火力地堡应用在Plunker不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是把一个应用程序我工作,并将其转换为普拉克,但角度和/或UI路由器不填充两种观点我在 index.html的。在我的本地主机应用程序加载正常,但我有应用模块化。所以,当我把它转换成一个普拉克,我不得不将文件重新连接在一起,因为我无法在Plunker AFAIK模块。此外,当我在一个单独的窗口,开放的开发工具加载普拉克我没有得到任何错误,所以我在亏损是现在。

I just took an app I'm working on and converted it to a Plunk but Angular and/or ui-router is not populating the two views I have in index.html. On my local box the app loads fine but there I have the app modularize. So when I converted it to a Plunk I had to rewire the files together since I can't make modules in Plunker AFAIK. Also, when I load the Plunk in a separate window and open Dev Tools I get no errors so I'm at a loss right now.

下面是链接到普拉克code我做:

Here is link to the Plunk code I made:

http://plnkr.co/edit/2f1RITT6ysZhB5i0UcUw?p=$p$ PVIEW

和这里是链接到嵌入式的视图(如果你想使用开发工具更方便):

And here is the link to the embedded view (more convenient if you want to use Dev Tools):

http://embed.plnkr.co/2f1RITT6ysZhB5i0UcUw/$p$pview/帖子

我要指出的路线在 /岗位,因为它命名为国家的网址帖子。我没有根 / 网​​址定义的状态。另外,以下网址失败:

I should mention that the route has to end in /posts since that it the url of the state named posts. I have no state defined for the root / url. Also the following url failed:

http://embed.plnkr.co/2f1RITT6ysZhB5i0UcUw/posts

先谢谢了。

推荐答案

我做了一些改动。这里是一个工作plunker

I've made few changes. Here is a working plunker

首先,我升级了您的版本的UI路由器0.2.13 (修复了一些问题,只要坚持使用最新的)

Firstly I upgraded your version to UI-Router 0.2.13 (fixes some issues, simply always use the latest)

在/后现在默认

//$urlRouterProvider.otherwise('/');
$urlRouterProvider.otherwise('/posts');

我改变你的控制器,不使用路由器的参数,可以

I changed your controller, to not use router params,

// wrong old 
/*
app.controller('ProfileCtrl', function ($scope, $routeParams, Profile) {
        var uid = $routeParams.userId;
        $scope.profile = Profile.get(uid);
         Profile.getPosts(uid).then(function(posts) {
            $scope.posts = posts;
        });
    });
*/

// the way with UI-Router
app.controller('ProfileCtrl', function ($scope, $stateParams, Profile) {
    var uid = $stateParams.userId;
    $scope.profile = Profile.get(uid); 
    ...

只是为了知道是什么的发布的控股结果
此外,通过用户id进入状态包含类似的值:simplelogin:82,观察taht,我加后处理,这正显示出这样的信息的概述:

JUST to know what is post holding
Also, the passed userId into state contains values like: "simplelogin:82", to observe taht, I added overview of processed post, which is showing info like this:

{
  "creator": "3lf",
  "creatorUID": "simplelogin:82", // this is passed as userId, is it ok?
  "title": "a",
  "url": "http://a",
  "$id": "-JazOHpnlqdNzxxJG-4r",
  "$priority": null
}

此外,这是一个固定的方式如何调用状态posts.postview

Also, this is a fixed way how to call state posts.postview

<!-- wrong -->
<!-- <a ui-sref="posts({postId:post.$id})">comments</a> -->
<!-- correct -->
<a ui-sref="posts.postview({postId:post.$id})">comments</a>

和阿洛斯,如果后览应注入主区,这应该是其确定指标

And alos, if the postview should be injected into main area, this should be its defintion

var postView = {
    name: 'posts.postview',
    parent: posts,
    url: '/:postId',
    views: {
        'navbar@': {
            templateUrl: 'nav.tpl.html',
            controller: 'NavCtrl'
        },
        //'@posts.postview': {
        '@': {
            templateUrl: 'postview.tpl.html',
            controller: 'PostViewCtrl'
        }
    }
};

检查所有这里

摘要:工作导航岗位之间 - 用户...评论的链接也在努力,但目标只是加载中...与许多其他错误...超出范围此处

SUMMARY: Working navigation is among posts - users... the "comments" link is also working, but the target is just loaded ... with many other errors... out of scope here

这篇关于AngularJS,UI路由器和放大器;火力地堡应用在Plunker不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆