angularjs-controller

How to handle multiple forms present in a single page using AngularJS

半世苍凉 提交于 2019-12-08 06:52:56
问题 I am a newbie in AngularJS. I am having multiple forms on a single page which gets displayed based on the user selection only one at a time. The DOM has two child controllers namely FirstFormController, SecondFormController wrapped under a parent controller named XceptionController . A parent controller function is used to submit the form data from both the children. The form data is saved on to the parent controller's scope.My HTML looks like below <div ng-app="app"> <div class="container"

ng-click not working inside the controller using of ng-bind-html

徘徊边缘 提交于 2019-12-07 08:55:14
问题 below my code ng-click not working,while i am checking the inspect element ng-click not showing, help me how to do var app = angular.module('myApp', ['ngSanitize']); app.controller('myCtrl', function($scope) { $scope.firstName = "<b ng-click=test(1)>John</b><br><b ng-click=test1(1)>Testing</b>"; $scope.test=function(val) { alert(val) } $scope.test1=function(val) { alert(val) } }); <!DOCTYPE html> <html> <script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"><

AngularJS - How to access to the next item from a ng-repeat in the controller

天大地大妈咪最大 提交于 2019-12-06 22:54:00
问题 I'd like to access to the parameters of the next item on screen when clicking on a button. I use a ng-repeat in my html file: <li ng-repeat="item in items | filter:query" ng-show="isSelected($index)"> <a href="" ng-click="itemNext()"><img src="xxx.jpg" /></a> </li> And the index in my Controller with a loop: $scope.itemNext = function () { $scope._Index = ($scope._Index < $scope.nbItems - 1) ? ++$scope._Index : 0; $scope.functionToCallWithNextItem(nextItem.param1); }; A simple $scope.items[

specifying AngularJS controller: benefits using ngController vs. $routeProvider

独自空忆成欢 提交于 2019-12-06 18:55:53
问题 There are two ways (AFAIK) to associate a controller with a view template/partial: the route specified in $routeProvider and the ngController directive. Especially (but not exclusively) for simple routing, is there any benefit/efficiency of one over the other? My project currently uses the $routeProvider approach, but I've been given the task of nesting views. This seems simple enough with ngInclude, as long as the partial specifies its ngController. 回答1: If you think of a view including all

Referencing the element that's calling a controller function Angularjs

蓝咒 提交于 2019-12-06 15:59:08
问题 Fairly simple but I can't figure out the term I need to google. How do I reference whichever element is calling the controllers blurr function? html <body ng-app="test"> <div ng-controller="Cntrlr as cntrlr"> <input type="text" ng-model="cntrlr.inpt" ng-blur="cntrlr.blurr()" /> <input type="text" ng-model="cntrlr.second" ng-blur="cntrlr.blurr()" /> </div> </body> js var app = angular.module("test", []); app.controller("Cntrlr", ["$scope", function($scope){ this.blurr = function(){ alert(

how to bind the relevant value in case of current status in ui-router?

大城市里の小女人 提交于 2019-12-06 09:30:36
问题 I have attached data attribute in each .state to identify the user (authenticated or public) as following (one state example) $stateProvider .state('admin-panel.public.home', { url: '/p', templateUrl: 'app/public/home.tmpl.html', controller: 'PublicHomeController', controllerAs: 'ctrl', data: { requireLogin: false } }); I need to use the some state for both of user (authenticated and public) as an example .state('403', { url: '/403', templateUrl: '403.tmpl.html', controller: function($scope,

how to display youtube thumbnail image from url with Angularjs

不打扰是莪最后的温柔 提交于 2019-12-06 07:05:36
问题 I just start to using angularjs and I want to display youtube thumbnail image from the youtube video url ... is there a way to display video thumbnail when people insert url in input and then click the button, PLUNKER http://plnkr.co/edit/9SBbTaDONuNXvOQ7lkWe?p=preview 回答1: Youtube provide default thumbnail image of its video. You can use below sample URL to create thumbnail image. http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg Where you need to search id from the given

AngularJS: Cannot interpolate attribute from first directive to a second. (w/ plunker example)

故事扮演 提交于 2019-12-06 04:25:42
Reference Reference plunker: http://plnkr.co/edit/otv5mVVQ36iPi3Mp0FYw?p=preview Explanation of the issue Suppose that we have two directives, first-directive and second-directive . Now suppose we only have access to first-directive which we hope to wrap second-directive with and pass to it our own manipulated attributes. app.directive('firstDirective', function() { return { scope: true, priority: 1000, transclude: true, template: function(element,attributes){ console.log('template') return '<second-directive two="{{one}}"></second-directive>' }, compile: function(element,attributes) { console

AngularJS - refresh view after http request, $rootScope.apply returns $digest already in progress

老子叫甜甜 提交于 2019-12-06 03:30:59
Hey guys so I am simply trying to load data when my app starts. However, the view loads faster than the http request(of course). I want to refresh my view once my data has been properly loaded because that data defines my view. I've tried $rootScope.apply from inside the factory where I do my http request, and I also tried directly doing the http request in my controller again with $scope.apply, and neither one worked as they both gave me "$digest already in progress" Any idea how can I set up my code to make my views refresh on data load? I will be having several different http requests and I

Angular minification with directive controller?

梦想与她 提交于 2019-12-06 00:42:21
问题 If I have the following: myapp.directive('directivename', ... return { ... restrict: 'E', controller: MyController, ... } function MyController($scope, $somethingelse) { // Contents of controller here } ); How do I modify this such that MyController will not get destroyed when minified? I am getting the following error: Error: [$injector:unpr] Unknown provider: eProvider <- e 回答1: It can be resolved by using explicit dependency annotation. What you have it implicit annotation which causes