angularjs-scope

How to get the form data when the form is in a directive in Angular?

女生的网名这么多〃 提交于 2019-12-08 10:49:04
问题 I have this this template: <div class="modal" id="popupModal" tabindex="-1" role="dialog" aria-labelledby="createBuildingLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title" id="createBuildingLabel">{{ title }}</h4> </div> <form data-ng-submit="submit()"> <div class="modal-body" data-ng-transclude> </div> <div class="modal

Create a list without ngRepeat

有些话、适合烂在心里 提交于 2019-12-08 10:28:27
问题 I would like to create a directive, that does not need ngRepeat, because there is some additional functionality on the directive, that doesn't play good with ngRrepeat. This is my directive with ng-repeat: <div> <ul> <li ng-repeat="item in items track by $index" ng-class="attrs.itemTheme" data-item="{{ item[attrs.itemId]}}"> <div ng-include="attrs.tpl"></div> </li> </ul> </div> attrs.tpl, nt-dimension is another directive, that uses the items values from ngRepeat: <script type="text/ng

how to add ng-include callback to multiple ng-include directives in angular js

六月ゝ 毕业季﹏ 提交于 2019-12-08 09:40:00
问题 I have my HTML like this <form ng-controller="testCtrl1"> <div ng-include="'test/views/navigationbar.html'"></div> <div ng-include="'test/views/processnav.html'"></div> <div ng-include="'test/views/leftprocesstabs.html'"></div> </div> </form> I want to write generalized method to check all my ng-include file are loaded. After loading all file i need to make a server call. Is there any way to check this in angular js? 回答1: use the onload of each template and increment a counter. if the form

how to empty reference object in angular js?

风流意气都作罢 提交于 2019-12-08 09:39:31
问题 I am trying to empty my reference object .But it is not deleting or removing my chart . I make two directive and communicate with shared service.But then I delete my reference object .it not deleted my chart ..on click of "delete" button i need to delete my chart .. is it possible ?because I take reference objects here is my code http://plnkr.co/edit/TzUlqoh4sYVjH3ADRTGL?p=preview angular.module('app',['header','chartm','hig']).controller('cntrl',function(){ }).service('sharedService'

Testing functions not on the scope in the controller

两盒软妹~` 提交于 2019-12-08 09:37:27
问题 I am using Karma test runner and Jasmine. I know how to test functions on the scope.But in case of a situation like this how do I go about it ? listing_app.controller('my_listing_products_list', ['$scope', '$modal', function ($scope, $modal) { this.someFn = function(a,b){ //How do i test this function ? } }]); How do I get hold of the this object and the controller context through Jasmine ? 回答1: Try the following: describe('my_listing_products_list controller', function(){ beforeEach(inject

Bind ngInclude to different models

梦想的初衷 提交于 2019-12-08 09:37:04
问题 Is it possible to specify model for ngInclude so that any changes done inside the included template are reflected on the specified model. For instance: I have a model such as : $scope.member = { name: "Member1", children:[ { name:"Child1" }, { name:"Child2" } ] }; and the template: <script type="text/ng-template" id="name.html"> <input type="text" ng-model="member.name"/> </script> Now is it possible to pass ngInclude either "member" or any child and get their respective name properties

Angular: $resource update fire PUT request on second call only

筅森魡賤 提交于 2019-12-08 08:03:51
问题 I have a resource with a custom update method : angular.module('user.resources', ['ngResource']). factory('User', function($resource) { var User = $resource('/user/:id', {}, { update: { method: 'PUT' } }); User.prototype.update = function(cb) { console.log('foo'); return User.update({ id: this._id }, angular.extend({}, this, { _id: undefined }), cb); }; I'm passing this resource to a custom directive via scope: directive('avatarUpload', function($http) { return { restrict: 'E', scope: { model

AngularJS - Pass dynamic object value and call function from Directive

我只是一个虾纸丫 提交于 2019-12-08 07:37:52
问题 Ctlr.js app.controller('myCtrl', function($scope) { $scope.data = { waterMarkImgPosition: [ {id: 'lowerRight', name: 'Lower Right'}, {id: 'lowerLeft', name: 'Lower Left'}, {id: 'upperRight', name: 'Upper Right'}, {id: 'upperLeft', name: 'Upper left'}, {id: 'center', name: 'Center'} ], selectedPosition: {id: 'upperRight', name: 'UpperRight'} //This sets the default value of the select in the ui }; $scope.watermarkPosition = $scope.data.selectedPosition.id; //pass default position for watermark

Undefined $http data when resolved with `.then` method

隐身守侯 提交于 2019-12-08 07:31:29
问题 I used the console log which returned the array of data fetched from the server, but when I call the scope on the html I get an undefined error on the console. app.service('blogpostservice', ['$http', function ($http) { this.getMoreData = function (pagecount) { return $http.get('/api/posts/' + pagecount); } }]); app.controller('MainController', ['$scope', 'blogpostservice', function ($scope, blogpostservice) { $scope.pagec = 1; this.getMoreData = function () { blogpostservice.getMoreData(

Angular - data not available inside ng-init

一世执手 提交于 2019-12-08 07:14:29
问题 Angular partial - HTML. BaseCtrl <div ng-controller="SelectTagCtrl"> <input type="text" ng-init="setTags(viewData['users'])" ui-select2="tagAllOptions" ng-model="tagsSelection" name="users" /> {{viewData['users']}} ECHOES CORRECTLY. But undefined when passed inside ng-init callback. </div> <input type="text" class="span12" placeholder="Brief Description" name="description" value="{{viewData['description']}}"> ECHOES CORRECTLY. Controller.js function SelectTagCtrl(){ $scope.setTags = function