Tag: angularjs

Angular js – route-ui添加默认参数

在我的应用程序中,我使用angular度UI路由器。 我有本地人(英语和希伯来语)我的基础语言是英语。 这就是为什么我想如果语言是英文不添加参数的url 例如: 主页英语 – > http://example.com/ Home希伯来语 – > http://example.com/he/ 关于我们English – > http://example.com/about 关于我们希伯来语 – > http://example.com/he/about 这可能吗 ? 这是我现在的代码 $stateProvider .state('/', { url: "/", templateUrl: "Assets/app/templates/home.html", controller: 'homeController' }) .state('activity', { url: "/activity", templateUrl: "Assets/app/templates/gallery.html", controller: 'galleryController' }) .state('page', { url: '/:pagename', templateUrl: "Assets/app/templates/page.html", controller: 'pageController' });

orderBy Angular ng-repeat中的数组项目值

我怎样才能得到Angular的ng-repeat指令来按每个项目的实际值sorting列表,而不是按每个项目上的属性值? 例如: <ul> <li ng-repeat="item in items | orderBy:'WHAT_GOES_HERE??'">{{item}}</li> </ul> 这是一个小提琴玩: http : //jsbin.com/okatur/1/edit 我意识到我可以在数组上做.sort() ,但这是我唯一的select吗?

问题与Android Hybid应用程序显示远程图像与Ionic框架?

我是离子的新手。 我使用的是Ionic Framework(1.3.20),Angular JS,Cordova 5.0.0 模板文件 browse.html代码: <div class="col-50"><img ng-src="{{availableImages[currentImage].src}}" /></div> app.js代码: .state('app.browse', { url: "/browse", views: { 'menuContent': { templateUrl: "templates/browse.html", controller: 'Ctrl' } } }) controller.js代码 .controller('Ctrl',function($scope) { $scope.currentImage = 0; $scope.availableImages = [ { src: "http://lorempixel.com/160/160/people/3" } ]; console.log("reading image in controller !!!"); }) 标题详细信息 : Request URL:http://lorempixel.com/160/160/people/3 Request Method:GET Status Code:404 […]

AngularJS:从string插入HTML

我已经看了很多,但是我找不到答案,或者我不明白。 一个具体的例子将赢得投票=) 我有一个函数返回一个HTMLstring。 我不能改变function。 我希望string表示的html被插入到DOM中。 我很高兴使用一个控制器,指令,服务,或其他任何工作(并且是相当好的做法)。 免责声明:我不明白$编译好。 以下是我所尝试的: // My magic HTML string function. function htmlString (str) { return "<h1>" + str + "</h1>"; } function Ctrl ($scope, $compile) { $scope.htmlString = htmlString; } Ctrl.$inject = ["$scope", "$compile"]; 这没有用。 我也试过它作为指令: // My magic HTML string function. function htmlString (str) { return "<h1>" + str + […]

Firefox CORS请求给予“跨源请求被阻止”,尽pipe标题

我试图做一个简单的跨源请求,Firefox一直阻止它与此错误: 跨源请求被阻止:相同来源策略不允许读取[url]处的远程资源。 这可以通过将资源移动到相同的域或启用CORS来解决。 [URL] 它在Chrome和Safari中正常工作。 据我可以告诉我已经在我的PHP上设置所有正确的标题,以允许这个工作。 这是我的服务器正在响应 HTTP/1.1 200 OK Date: Mon, 23 Jun 2014 17:15:20 GMT Server: Apache/2.2.22 (Debian) X-Powered-By: PHP/5.4.4-14+deb7u8 Access-Control-Allow-Origin: * Access-Control-Allow-Methods: GET, POST, OPTIONS Access-Control-Allow-Headers: Content-Type Access-Control-Request-Headers: X-Requested-With, accept, content-type Vary: Accept-Encoding Content-Length: 186 Content-Type: text/html 我试过使用Angular,JQuery和一个基本的XMLHTTPRequest对象,就像这样: var data = "id=1234" var request = new XMLHttpRequest({mozSystem: true}) request.onload = onSuccess; request.open('GET', […]

如何使用HTML内容创buildAngularJS UI引导popup窗口?

我想创build一个带pre pre标签JSON对象的prestrap popover。 天真的执行, <span popover='<pre>{[ some_obj | json:" " ]}</pre>' popover-trigger='mouseenter'> 在将内容插入到popup窗口之前将内容转义。 用html内容指定popover正文的最佳方法是什么?

如何从angularjs从另一个控制器调用一个函数?

我需要在另一个控制器angularJS调用函数。请问如何提前帮助我 代码: app.controller('One', ['$scope', function($scope) { $scope.parentmethod = function() { // task } } ]); app.controller('two', ['$scope', function($scope) { $scope.childmethod = function() { // Here i want to call parentmethod of One controller } } ]);

AngularJS自定义filterfunction

在我的控制器里面,我想过滤一个对象数组。 这些对象中的每一个都是可以包含string以及列表的映射 我尝试使用$filter('filter')(array, function)格式,但我不知道如何访问我的函数内的数组的个别元素。 这是一个片段,显示我想要的。 $filter('filter')(array, function() { return criteriaMatch(item, criteria); }); 然后在criteriaMatch() ,我将检查每个属性是否匹配 var criteriaMatch = function(item, criteria) { // go thro each individual property in the item and criteria // and check if they are equal } 我必须在控制器中完成所有这些工作,并编制一个列表清单,并将其设置在范围内。 所以我确实需要以这种方式访问$filter('filter') 。 到目前为止,我在networking中find的所有示例都在函数内部都有静态标准search,它们不会传递一个标准对象并针对数组中的每个项目进行testing。

angular.js链接行为 – 禁用特定url的深层链接

我有一个启用了HTML5模式的工作Angular.js应用程序。 $location.Html5mode(true).hashbang("!"); 我想实现的是获取一些URL或<a>标签来执行正常的浏览行为,而不是使用HTML5历史API更改地址栏中的URL并使用Angular控制器处理它。 我有这个链接: <a href='/auth/facebook'>Sign in with Facebook</a> <a href='/auth/twitter'>Sign in with Twitter</a> <a href='/auth/…'>Sign in with …</a> 我希望浏览器将用户redirect到/auth/…这样用户将被redirect到authentication服务。 有什么办法可以做到这一点?

我怎样才能使AngularJS指令停止传播?

我试图“停止传播”,以防止点击一个li中的元素(链接)时closuresTwitter Bootstrap navbar下拉菜单。 使用这种方法似乎是常见的解决scheme 。 在Angular中,看起来像一个指令是做这个的地方吗? 所以我有: // do not close dropdown on click directives.directive('stopPropagation', function () { return { link:function (elm) { $(elm).click(function (event) { event.stopPropagation(); }); } }; }); …但方法不属于元素: TypeError: Object [object Object] has no method 'stopPropagation' 我把这个指令和 <li ng-repeat="foo in bar"> <div> {{foo.text}}<a stop-propagation ng-click="doThing($index)">clickme</a> </div> </li> 有什么build议么?