Tag: angularjs

AngularJS路由问题的url不好

在我的应用程序中生成我的路线: app.config( function($routeProvider){ $routeProvider .when('/',{ templateUrl: './partials/home/home.html', controller: 'mainCtrl'} ) .when('/article',{ templateUrl: './partials/article/article.html', controller: 'articleCtrl'} ) .otherwise({ redirectTo: '/' }); }); 它正在工作! 但链接是bas :(我创build我的链接像这样: <div class="read-more"><a href="#article">Lire plus…</a></div> 我的坏链接: http:// localhost:10001 /#!/#文章 vs好链接是: http:// localhost:10001 /#!/ article 谁错了? 谢谢 PS我使用节点Lite服务器

为什么$ http.get返回304错误

我是新来的angular度和麻烦,总是工作的服务,直到它没有。 我的服务有以下电话。 this.getForms = function() { return $http.get("/forms"). then(function(response) { return response; }, function(response) { alert("Error finding forms."); }); }; 刷新页面(safari)getForms被触发时,调用$ http.get,我的Node.js / Express服务器窗体端点正确地返回表单数据。 app.get("/forms", function (req, res) { Form.find({}, function (err, docs) { if (err) { server.handleError(res, err.message, "Failed to get forms."); } else { res.status(200).json(docs); } }); }); 但是,而不是JSON我得到一个304错误,这表明数据在caching中可用。 但304响应头有一个空的数据string,所以它不会从caching中返回任何数据。 我的问题是 1)如果数据在caching中可用,为什么它调用我的服务器? 2)我怎么能告诉它不caching这个调用,所以页面可以正确更新表单?

Angular – Node – 可以告诉节点从哪个路由请求块

是否有可能告诉我的节点应用程序req在: app.get('/*', function(req, res) { res.sendFile(__dirname + '/site/index.html') }); 我的angular路线从哪个方块出来(即我希望能够识别来自otherwise方块的什么); .when('/user', {…} ) .when('/login', {…} ) .otherwise( {…} ) 我想要的原因是因为我想要做这样的事情: app.get('/*', function(req, res) { if (req is from otherwise block) { res.status(400).sendFile(__dirname + '/site/index.html') } else { res.sendFile(__dirname + '/site/index.html') } }); 我唯一能想到的是创build一个所有允许的路由的数组,但是我不喜欢重复:p

在使用AngularJS创buildinput之后着重于input

我一直在用AngularJS做一个待办事项列表,想知道在创build一个input框后,是否有一种方法可以通过点击一个button来创build。 实际上,我在控制器中的保存function是这样定义的: $scope.save = function() { $scope.objetivo.$save() .then(function() { $scope.message = { text : 'Saved' }; $scope.objective = new Objective(); }) .catch(function(err) { console.log(err.data); if(err.data.code === 11000) { text = 'This objective is already registered' } $scope.message = { text : text || "Error when saving" }; }); }; 我认为可能是通过添加input框然后专注于它,但我不知道如何去做。

将angularjs应用程序从Windows移动到Ubuntu

我使用nodejs,http-server,gulp和brackets在窗口上开发了一个angular度应用程序。 在Windows中我有一个根目录(lms)包含: /src /src/templates /src/js /src/img /src/index.html /node_modules package.json 在Ubuntu中,我有一个名为/ home / lms的目录。 我已经安装了nodejs,angularjs和http服务器,但不是吞咽或凉亭,因为我不会在Ubuntu中进行开发。 我在家看到/ lms: /Public /Templates /Pictures /node_modules 我如何部署我的文件? 我假设我把我的package.json放在home / lms中,但是我不能将Windows node_modules复制到Ubuntu node_modules,所以如何为Ubuntu创buildnode_modules? 另外,我把我的应用程序目录/ src放到Ubuntu的/ home / lms / Public目录下,或者只是把它添加到/ home / lms?

如何限制ng-repeat中重复的项目数量。 angularjs?

我正在接触卡工作。 我需要在列表中添加姓名和联系电话号码。 但条件是名称和联系人必须添加2次。 例如。 联系人卡片-1 名称-A 名称-B 联系-1 联系-2 每当我点击button我的名字和联系人被添加到列表中,但具有一定的条件。 我的代码是 <md-list-item ng-show="showContactList" class="md-2-line" ng-repeat="numbers in contactList track by $index" > <i ng-show="numbers.type == 'test'" class="material-icons md-avatar-icon">textsms</i> <i ng-show="numbers.type == 'CELL' || numbers.type == 'EXT'" class="material-icons md-avatar-icon">phone</i> <div class="md-list-item-text" ng-class="{'md-offset': phone.options.offset }"> <h3> {{ numbers.type }} </h3> <p> {{ numbers.value }} </p> </div> <i class="material-icons […]

从<iframe>或<object>中获取variables的值

在我的全局html模板中,我embedded了一个iframe ,它可以实时预览{{src}} (例如, src可以是public/tmp/bDCZ5rynnpLaYNEuAAAj/index.html )。 <iframe id="myiframe" ng-src="{{src}}"></iframe> index.html是由我的服务器写的文件; 我有代码的控制,我可以修改它。 index.html包含JavaScript代码,它被devise为始终有一个内部variables$output 。 我的问题是,如何从iframe获取$output的值,并让全局html页面知道这个值。 有谁知道如何做到这一点? 编辑1:我也打开解决scheme,其中index.html可以将值发送到服务器或创build一个文件的值,只要全局模板可以得到它。 此外,正如我在评论中提到的, iframe的目的是实时预览文件的文件夹,还有其他的方式 (例如,使用<object> ),有谁知道哪种方式可以让我得到一个内部值出来吗? 编辑2:我做了一个与iframe和一个运动员与对象的运动员 。 $output由indexOutput.html中的<script>var $output="Default"</script> 定义 。 我的目标是获得这个价值。 编辑3:我只是意识到@Roybuild议在他的答案作品window.parent._resetter 。 但有一点是, _resetter函数必须在html页面的脚本中定义。 有谁知道如何将这个值传递给我的控制器 ? 这里是一个笨蛋 ,还有一个有$ window的笨蛋 。

社交authentication – 在FE或BE方面做得更好?

如果我们想要进行社交authentication(例如Facebook或Google ),那么哪一方最好将其整合。 后端侧还是前端侧? 对于后端我们有NodeJS ,我们可以使用PassportJS来做到这一点,对于前端我们有Angular2.0 ,也有插件可以做到这一点。 我有点困惑这个代码应该驻留在哪一边。 如果有人对此有任何看法,请让我知道。

AngularJS显示MongoDB数据

我与AngularJS和MongoDb的交互有问题。 我在服务器端使用NodeJS和ExpressJS。 用mongoose,我跟Mongo说话。 我刚刚完成了路线。 index.js app.get('/api/dashboard', function (req, res) { Homepage .find({}, 'title -_id createdBy allbids.bid endTime') .exec(function (err, auctions) { if(err) res.send(err); console.log(auctions); res.json(auctions); }) }); 控制台显示我需要的所有字段。 然后我通过前端。 我以这种方式使用Angular路线: var app = angular.module('auction', [ 'ngRoute','HomeCtrl','NewAuctionCtrl', 'FollowingAuctionsCtrl', 'MyAuctionsCtrl']); app.config(function ($routeProvider, $locationProvider) { $routeProvider .when('/', { templateUrl: 'views/partials/dashboard.html', controller: 'HomeController' }) $locationProvider.html5Mode(true); }); 而我的HomeController是这样的: angular.module('HomeCtrl', []) […]

生产和开发中需要哪些节点模块?

除了在项目中使用的最小文件以外,是否可以安全地删除节点模块库中的其他文件夹 ? 例如:使用angular度uiselect库下拉 仅使用来自 – node_modules / dist / select.min.js,select.min.css的最小文件 (思考使用CDN,而在节点模块中创build的库是巨大的额外的文件夹,如src,文档,testing..)