angularjs-directive

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

寵の児 提交于 2019-12-10 04:10:17
问题 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

What is Default Header Cell Template of UI-GRID?

。_饼干妹妹 提交于 2019-12-10 03:54:11
问题 The ng-grid documentation contains default Header Cell Templates (as well as other default templates). What is the default header cell template for ui-grid? 回答1: Per the githubs https://github.com/angular-ui/ui-grid/tree/master/packages/core/src/templates/ui-grid The current default header cell template is <div ng-class="{ 'sortable': sortable }"> <!-- <div class="ui-grid-vertical-bar"> </div> --> <div class="ui-grid-cell-contents" col-index="renderIndex" title="TOOLTIP"> <span>{{ col

scope.$watch in directive link function not getting called

南笙酒味 提交于 2019-12-10 03:46:44
问题 I have this factory, .factory('authentication', [function() { return { loginRequired: false }; }]); I have this controller, .controller('TopNavCtrl', ['$scope', 'authentication', function($scope, authentication) { $scope.login = function() { authentication.loginRequired = true; }; }]); and I have this link function in a directive, link: function(scope, element, attrs) { scope.show = false; scope.$watch(authentication.loginRequired, function(value) { scope.show = value; }); } When

Passing a binding to transcluded scope in component

时光总嘲笑我的痴心妄想 提交于 2019-12-10 02:45:02
问题 In AngularJS 1.5, I want to pass a binding from a component into the (multi-slot) transcluded scope - for a reference in the template (in either one specific or all of them - no either way is fine). This is for creating a generic custom-select list // Component .component('mySelect', { bind: { collection: '<' }, transclude:{ header: 'mySelectHeader', item: 'mySelectItem' }, templateUrl: 'my-select-template', controller: function(){ ..... } }); ... // Component template <script id="my-select

AngularJS equivalent for Angular ng-container

爱⌒轻易说出口 提交于 2019-12-10 00:50:43
问题 Is here an AngularJS equivalent for Angular ng-container? Or should I create something myself with a transclude directive? Example use cases: Tables with interlaced pairs, triples etc. of cells: <table><tr> <ng-container ng-repeat="item in items"> <td>{{ item.a }}</td> <td>{{ item.b }}</td> </ng-container> </tr></table> There should not be additional level in the DOM tree, and instead <td> s should be direct children of <tr> element. There is similar problem with HTML lists, especially the

Google map fitBounds not working

被刻印的时光 ゝ 提交于 2019-12-09 21:02:05
问题 I am creating a trip view using google map with angularjs directive. All works fine except the google map fitbound to a latitude longitude collection. I have tried all the way to use the fitbounds methods but failed. Thanks, Below is my code efforts. Directive: <div class="trip-google-map" trip-map="" mapid="2" latitude="22.998673" longitude="72.514346"></div> Directive Code: app.directive('tripMap', function ($compile) { return { controller: function ($scope, $location, mapService) { this

Difference between $scope and scope in angularjs

旧街凉风 提交于 2019-12-09 19:15:31
问题 I am new to angularjs. I would like to know what is the difference between $scope in angularjs Controller and scope in angularjs Directive. I tried to use scope in controller and I got the below error: Error: [$injector:unpr] Unknown provider: scopeProvider <- scope 回答1: $scope is a service provided by $scopeProvider . You can inject it into controllers, directives or other services using Angular's built-in dependency injector: module.controller(function($scope) {...}) which is shorthand for

Partially read-only textbox

谁说胖子不能爱 提交于 2019-12-09 18:20:27
问题 How to make a text-box partially readonly using angularjs/HTML attribue? For example, a textbox having default value say "+91",which is readonly and else part need to enter values. 回答1: HTML <input id="field" type="text" value="+91" size="50" /> <div id="output"> </div> Javascript var readOnlyLength = $('#field').val().length; $('#output').text(readOnlyLength); $('#field').on('keypress, keydown', function(event) { var $field = $(this); $('#output').text(event.which + '-' + this.selectionStart

AngularJs pass instance of each ng-repeat in HTML to directive

和自甴很熟 提交于 2019-12-09 17:56:00
问题 I'm thinking this should be simple but I'm missing something. How can I pass a flowObj in my ng-repeat below to my Directive? I want to pass it to my directive then on click use that FlowObj then apply some logic. I tried using the commented code in my directive scope: { test:"@" } But it seems to screw up my css . HTML: <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <div id="center_outer"> <div id="center_inner" ng-controller=

AngularJS ng-model value is lost after custom validation directive is triggered

╄→гoц情女王★ 提交于 2019-12-09 17:53:49
问题 I created a custom validation directive and used it in a form. It can be triggered with no problem, but after the validation is triggered, I found that the model value is just lost. Say I have ng-model="project.key" and after validation, project.key doesn't exist in the scope anymore. I think somehow I understood AngularJS wrong and did something wrong. Code speaks. Here is my html page: <div class="container"> ... <div class="form-group" ng-class="{'has-error': form.key.$invalid && form.key.