angularjs-controller

How to update Directive on State Changes

主宰稳场 提交于 2019-12-05 23:20:02
I have a root state that defines the overall structure of the Angular template. In the root state, I have the sidebar included that has dynamic menus via directive that changes based on the state. Like this: .state(‘root', { abstract: true, url: ‘/root', templateUrl: ‘views/root.html', }) root.html includes the sidebar.html that has dynamic menu called through Directive like this: sidebar.html <ul class="nav" id="side-menu"> <li class="nav-header"> <img alt="avatar" ng-src="{{ avatar }}" /> </li> <!—Dynamic Menus Directive --> <li sidebar-menus></li> </ul> The directive shows the menu based on

ng-repeat inserting empty anchor tags

假如想象 提交于 2019-12-05 21:27:34
I'm trying to create a menu using angular. A menu item can have children requiring another ng-repeat to print the sub nav items. I'm noticing some strange behavior when attempting to insert an anchor tag within the 2nd ng-repeat. Link to fiddle: http://jsfiddle.net/npU7t/ <li ng-repeat="sub_menu_item in menu_item.sub_menu"> <a href=""> {{ sub_menu_item.title }} </a> </li> With { title: 'menu item with children', sub_menu: [ { title: '<-- empty anchor tag???' } ] } Results in <li ng-repeat="sub_menu_item in menu_item.sub_menu" class="ng-scope"> <a href=""></a> <a href="" class="ng-binding"><--

AngularJS Drop down values change Dynamically

戏子无情 提交于 2019-12-05 17:59:08
I have created two drop downs using AngularJS and appended data in them through the controllers. I want to change the second drop down values when a change occurs in first drop down. I create the example , but when I change value of the first drop down; the second drop down values do not change. Updated HTML: <div ng-controller="exerciseTypeCtrl"> <ul data-role="listview" data-inset="true" > <li> <select id="exerciseSuperCategory" data-role="listview" ng-options="catagory as catagory.text for catagory in catagories.cast " ng-model="itemsuper" ng-change="changeData()"> </select> </li> </ul> <ul

Get parent controller in child controller which all use 'controller as vm' notation

霸气de小男生 提交于 2019-12-05 17:12:05
Parent controller set to ' parentCtrl as vm ' and chield set to ' childCtrl as vmc ' to be no name conflict and it works well. How can I get access to parent controller in child controller? Note that '$scope.$parent' did not work. To access the parent controller using the '$scope' notation just use '$scope.$parent'. However the 'controller as vm' notation lacked a detail that makes it work with some behavior: '$scope.$parent. vm ' app.controller('childCtrl', [ '$scope', function ($scope) { var vmc = this; // To protected access as vmc.parent Object.defineProperty(vmc, 'parent', { get: function

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

有些话、适合烂在心里 提交于 2019-12-05 16:16:43
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"></script> <script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular-sanitize.js"></script>

Angular ui.router, call parent controller function from child controller?

こ雲淡風輕ζ 提交于 2019-12-05 15:46:06
问题 I'm using Angular with ui.router and have setup a nested view. The parent view has a div whose visibility I can toggle through a function on the parent controller. I'd like to call this function from the child controller of the nested view. How would I do this? 回答1: http://plnkr.co/edit/zw5WJVhr7OKqACoJhDZw?p=preview JS angular .module("myApp", []) .controller("parent", function($scope) { $scope.parentFunction = function() { alert("Called a function on the parent") }; }) .controller("child",

AngularJs Directives Loaded Event

让人想犯罪 __ 提交于 2019-12-05 08:17:47
I have just started using AngularJs directives, using the resources here , here and here . I have a situation where i need to do something after all directives have been loaded. i.e Scenario 1 Controller Loads Directive 1 loads Directive 2 loads Final event fires (preferably picked up by the controller) Scenario 2 Controller loads Directive 1 loads Directive 2 loads Directive 3 loads Final event fires (preferably picked up by the controller) I can't seem to find a 'directives loaded' event. With a search, the best I could find was this SO post , (for which this answer does work), but it feels

Pass Data $http.post From AngularJS and ASP.net MVC gets null

喜你入骨 提交于 2019-12-05 05:45:38
i'm trying to pass data from AngularJS to ASP.net MVC and is always getting null. Here's my code (only posting the essential, button, controller and c#: HTML: <a class="btn btn-grey btn-lg btn-block" ng-click="AddCar()">Save</a> Controller $scope.AddCar = function () { $http.post("Cars/AddCar", JSON.stringify($scope.new.JsonCar)).success(function (data) { Alert(ok) }) c# public string AddCar(string JsonCar) { try .... } In JSON.stringify($scope.new.JsonCar) i'm getting this: "{"Name":"FIAT 500","Description":"New car","MaxUserCapacity":5,"PhotoPath":"none"}" What i'm doing wrong? Pass your

Getting AngularJS Error: “[$rootScope:inprog] $digest already in progress” without a manual $apply

风格不统一 提交于 2019-12-05 01:25:25
Other posts on this error always include someone trying to $apply without using a safe apply, but that's not the case in my example. My function IS successfully returning the data I requested from the API, but I can't clean this bug and it's driving me nuts. Every time before the .success is called in my $http function I get "Error: [$rootScope:inprog] $digest already in progress" in the console. Below are my controller and service. Thanks! Here's my service including a function to post an $http call with a payload: Services.service( 'CoolService', ['$q', '$rootScope', '$http', 'Auth',

Referencing the element that's calling a controller function Angularjs

淺唱寂寞╮ 提交于 2019-12-04 22:43:31
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("which input am I?"); alert("this is so meta."); // ? }; }]); [edit] I realized I meant to be more abstract