angularjs-scope

AngularJS - change href Attribute based on current path

和自甴很熟 提交于 2019-12-12 02:07:41
问题 How can I change the value of the href-Attribute based on the current path? My if clause in AngularJS looks like this: if (newPath.indexOf('test') > -1) { // change the value of the href-Attribute } else { // don't change the value of the href-Attribute } My HTML looks like this: <li> <a aria-expanded="false" role="button" href="/path1/path2/path4">Downloads</a> </li> 回答1: you can use ng-href to dynamically assign value to href <li> <a aria-expanded="false" role="button" ng-href="{{myVar}}"

Angular scope - Isolated VS Inherited. Which one is more restrictive

ε祈祈猫儿з 提交于 2019-12-12 02:06:46
问题 I have seen several you tube videos and read other stack overflow threads but still cannot figure out which one of angular scope is more restrictive. Isolated or Inherited. From the name isolated it feels if it is the most restrictive scope but since it allows various settings like @, =, and & to me it seems less restrictive then inherited scope. So the question is which one is more restrictive and why ? 回答1: I'd venture a guess that your definition of "restrictive" has to do with access to

Angular 1.3 breaking changes - scope set but reset before $apply

孤者浪人 提交于 2019-12-12 01:54:50
问题 AngularJs 1.3.x, simple controller works but as soon as I re-write it using Typescript and Injection, it fails. If I reference 1.2.x it starts working again. //This works in 1.3.x scopeApp.controller('MyController', ['$scope', function ($scope) { $scope.username = 'World'; $scope.sayHello = function () { $scope.greeting = 'Hello ' + $scope.username + '!'; }; }]); http://plnkr.co/edit/ssSuuZuGlrypemx3BU5r?p=preview //This DOES NOT works in 1.3.x but does in 1.2.x //The following code is

Sync child scope var with parent var

那年仲夏 提交于 2019-12-12 01:49:45
问题 I have a question about how angular decides to create new child scope variable. http://plnkr.co/edit/Dlsh6WJA1hrCpBgm5IrI?p=preview JS angular.module('myapp', []) .controller('HomeCtrl', function($scope) { $scope.aaa = 10; $scope.clickMe2 = function() { $scope.aaa++; } }) .controller('TestCtrl', function($scope) { $scope.clickMe1 = function() { $scope.aaa = $scope.$parent.aaa || 9; $scope.aaa++; } }) HTML <div ng-controller="HomeCtrl"> <p>{{ aaa }}</p> <a ng-click="clickMe2()" href="">Click

how to display sorted only 25 element in infinite scroll?

混江龙づ霸主 提交于 2019-12-12 01:47:07
问题 I am using infinite scroll in my demo ,In which I am showing only 25 element first time .When user scroll down to bottom it load more data and display that more data .It is do repeat steps if user want whole data to display (scroll to bottom load more data).but in my demo there is ascending and descending functionality present .On header there is "V" and "^" Button present .using click of that button I need to ascend and descend data .In my demo it is working fine .But the issue is when user

Sorting table columns in AngularJS

被刻印的时光 ゝ 提交于 2019-12-12 01:46:11
问题 The following code for sorting table columns doesn't work. I get an Error message: Error: $injector:unpr Unknown Provider Unknown provider: orderbyFilterProvider <- View: <table class="table table-bordered table-hover"> <thead> <tr> <th><a href="" ng-click="reverse=!reverse;order('lname', reverse)">Lastname</a></th> <th><a href="" ng-click="reverse=!reverse;order('fname', reverse)">Firstname</a></th> <th><a href="" ng-click="reverse=!reverse;order('maxAge', reverse)">Age</a></th> </tr> <

angular: watch for filtered value in directive

吃可爱长大的小学妹 提交于 2019-12-12 01:36:46
问题 I'm trying to implement a directive that draws a chart based on given values. I want the pass the data for the plot from the template. I have a working solution, passing the data in ng-model , for which I can then add a $scope.watch statement. But that doesn't work with filtered data, and I don't need two-way binding. Ideally, the html should look like: <chart ???????="list | filter" /> The directive, I guess, should look like: return{ restrict: 'C', link: function(scope, elem, attrs){ var

can't getting textarea value using AngularJs

ぃ、小莉子 提交于 2019-12-12 01:36:23
问题 <tr class="labels"> <td nowrap="nowrap">Address</td> <td nowrap="nowrap"><label for="tbAddress"></label> <textarea name="tbAddress" id="tbAddress" cols="39" rows="5" ng-model="$parent.tbAddress"></textarea> </td> </tr> <tr> <td> </td> <td align="right"> <input type="submit" name="button" id="button" value="Submit Record" class="btns" /> <input type="reset" name="button2" id="button2" value="Cancel" class="btns" /> </td> </tr> I'm not be able to get textarea value using AngularJS. All the

How to use $emit and $on of angularjs for two different controller stored in different path

你说的曾经没有我的故事 提交于 2019-12-12 00:49:26
问题 I have two views and its resp controller. Say view1.html and its controller firstCntrl and view2.html and its controller secndCntrl. In view1.html : There is Link2 which will be redirected to view2.html if it is clicked. <a href="#/view1" ng-click="emit()">Link1</a> <a href="#/view2" ng-click="emit()">Link2</a> in ng-click I am calling emit function where I defined $emit as firstCntrl.js app.controller("firstCntrl", function ($scope) { $scope.emit = function() { $scope.$emit('send', { message

AngularJS: model data from http call not available in directive

£可爱£侵袭症+ 提交于 2019-12-12 00:36:42
问题 There seems to be a bug where model data fetched from an http call is present in the $scope but not in a directive. Here is the code that illustrates the problem: Jsfiddle: http://jsfiddle.net/supercobra/hrgpc/ var myApp = angular.module('myApp', []).directive('prettyTag', function($interpolate) { return { restrict: 'E', link: function(scope, element, attrs) { var text = element.text(); //var text = attrs.ngModel; var e = $interpolate(text)(scope); var htmlText = "<b>" + e + "</b>"; element