Tag: angularjs

离子请求返回404只在Android上,在Chrome中工作正常

所以,我已经从离子克隆了教程应用程序回购。 我跑了 ionic start conference sidemenu 然后我添加了一个简单的$ http.get('myserver')(我也试过ngResources)。 它工作完美的铬,我得到的所有数据,但在angular度上,我只有null数据和404状态的任何要求,我试图做的。 注意:我尝试使用托pipe服务器和本地服务器。 在Android上都失败。 服务器是一个node.js REST API。 控制台上没有打印任何内容,所以请求甚至不会到达服务器。 有没有人经历过或可以告诉我如何debugging使用离子build立的Android应用程序? 编辑1:我不知道你为什么需要它,但在这里 $http.get('http://server.com/route').success(function (data) { //handle success }).error(function (data, status) { // handle error });

使用ng-click来调用两个不同的函数

有没有办法我可以用ng-click来调用两个函数? 我想要的东西 ng-click ="{search(),match()}" 而不是我现在怎么做,这是: ng-click = "search()"

$ scope。$ root和$ rootScope有什么区别?

我在控制器中看到$ scope有$ root,这是什么? 它和$ rootScope有什么不同,它可以注入到控制器中?

离子 – 如何删除login页面上的sidemenu只?

我只需要在我的login页面上删除sidemenu。 否则保持。 如何做到这一点? 我正在使用命令离子ionic start myApp sidemenu来创build项目。 app.js .config(function($stateProvider, $urlRouterProvider) { $stateProvider .state('login', { url: "/login", templateUrl: "templates/login.html", controller: 'LoginCtrl' }) .state('app', { url: "/app", abstract: true, templateUrl: "templates/menu.html", controller: 'AppCtrl' }) .state('app.search', { url: "/search", views: { 'menuContent' :{ templateUrl: "templates/search.html" } } }) login页面 <ion-view title="Login"> <ion-content> <div class="list"> <label class="item"> <button class="button […]

我将如何testingJasmine中的$ scope.watch(AngularJS)更改?

我刚刚开始写AngularJS的东西,我不知道如何去写这个特定的东西testing。 我正在构build具有不同状态的“帮助请求”模式。 所以在我的控制器中,我使用$ scope.request_modevariables。 激活帮助请求的不同链接将该variables设置为不同的内容。 然后在我的指令里面,我做了$scope.$watch('request_mode', function(){…}); 以在请求模式改变时select性地激活或停用事物。 代码都很好,但是我遇到的问题是testing。 我似乎无法让Jasmine拿起$scope.$watch ,实际上当它发生变化时会触发任何东西。 我敢肯定有人遇到过这个,所以任何build议将非常感激。

用angular.js重置一个模型

我只是试图重置像这样的值: $scope.initial = [ { data1: 10, data2: 20 } ]; $scope.datas= $scope.initial; $scope.reset = function(){ $scope.datas = $scope.initial; } 但它不产生任何东西,任何想法来解决它? angular.module('app', []).controller('MyCtrl', function($scope) { $scope.initial = [ { data1: 10, data2: 20 } ]; $scope.datas= $scope.initial; $scope.reset = function(){ $scope.datas = $scope.initial; } }); <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app="app" ng-controller="MyCtrl"> <div ng-repeat="data in datas"> <input […]

AngularJS:工厂$ http服务

我正在尝试了解Angular的工厂和服务的概念。 我在控制器下面有下面的代码 init(); function init(){ $http.post('/services', { type : 'getSource', ID : 'TP001' }). success(function(data, status) { updateData(data); }). error(function(data, status) { }); console.log(contentVariable); }; function updateData(data){ console.log(data); }; 这段代码工作正常。 但是当我移动$ http服务到工厂,我不能够返回数据回控制器。 studentApp.factory('studentSessionFactory', function($http){ var factory = {}; factory.getSessions = function(){ $http.post('/services', { type : 'getSource', ID : 'TP001' }). success(function(data, status) { return data; […]

Angular UI路由器:如何防止访问状态

你好,我是angularJS的新手,并试图阻止访问基于用户标识的某些状态。 这从ui路由器的FAQ描述了我想要做什么,但是我不能让它正常工作。 我需要什么,但在数据对象完全是为了完成这个? (我看到有人在一些博客文章中引用了“真实”,并像我一样使用它,但似乎没有工作,因为我得到一个错误,说明needAdmin没有定义) 这是我的代码: angular.module('courses').config(['$stateProvider', function($stateProvider) { // Courses state routing $stateProvider. state('listCourses', { url: '/courses', templateUrl: 'modules/courses/views/list-courses.client.view.html' }). state('createCourse', { url: '/courses/create', templateUrl: 'modules/courses/views/create-course.client.view.html', data: { needAdmin: true } }). state('viewCourse', { url: '/courses/:courseId', templateUrl: 'modules/courses/views/view-course.client.view.html' }). state('editCourse', { url: '/courses/:courseId/edit', templateUrl: 'modules/courses/views/edit-course.client.view.html', data: { needAdmin: true } }); } ]); angular.module('courses').run(['$rootScope', '$state', […]

AngularJs删除ng-repeat中的重复元素

我有一个存储在field_detail字典 <li ng-repeat = "field in field_detail">{{field.displayName}}</li> 现在我不想包含field_detail重复displayName ,我应该使用什么样的filter ?

如何在angular度路由中传递查询string?

我正在使用AngularJS路线,并试图查看如何使用查询string(例如, url.com?key=value )。 Angular不理解包含相同名字albums的键值对的路线: angular.module('myApp', ['myApp.directives', 'myApp.services']).config( ['$routeProvider', function($routeProvider) { $routeProvider. when('/albums', {templateUrl: 'albums.html', controller: albumsCtrl}). when('/albums?:album_id', {templateUrl: 'album_images.html', controller: albumsCtrl}). otherwise({redirectTo: '/home'}); }], ['$locationProvider', function($locationProvider) { $locationProvider.html5Mode = true; }] );