Search Posts

Category: angularjs-ng-click

Ng-click not working but other ng-click working

I want to ask you some help in AngularJS. ng-click is not working on my code. here is the html: <div layout=”row” layout-align=”center center” ng-controller=”viewClasslistCtrl”> <div layout=”row” layout-wrap style=”padding-bottom: 32px;” ng-cloak> <span class=”deleteStud” ng-click=”deleteBtn(skey)”><img src=”assets/redclose.png”></span> </div> <md-button class=”btn rp-btn” ng-click=”test()” style=”width: 150px;”> Save </md-button> </div> here is the script: angular.module(“myApp”).controller(‘viewClasslistCtrl’, function ($scope, $http, $rootScope, $sce, selectedItem, assignmentModel, classModel, $timeout, $mdSidenav, $state, $mdDialog, $mdMedia, $log, $mdToast, studentListModel, courseModel, util) { $scope.test = function () { alert(“test”); […]

ng-click on img not working inside ng-repeat

In my view I have a list of icons that when clicked, should call a function from the controller. View <div ng-controller=”EditorController” class=”main-div”> <aside> <div ng-repeat=”icon in EditorIcons”> <img ng-click=”changeme()” data-ng-src=”{{icon.source}}” alt=”{{icon.name}}”/> </div> </aside> </div> Controller app.controller(‘EditorController’, function($scope) { $scope.EditorIcons = [ … ]; $scope.changeme = function() { console.log(“changing”); } } I’ve seen this question asked before, yet I still wasn’t able to find out the problem here. What am I doing wrong? UPDATE I’ve […]

AngularJS Select Tab from Button Click

Using the AngularJS tabs directive, is there a way to select a tab from a button. Effectively what I would like to do is click the button ‘Select Tab 3’ and the third tab will be selected. <md-button id=”button” class=”md-raised”>Select Tab Three</md-button> <div ng-cloak> <md-content> <md-tabs md-dynamic-height md-border-bottom> <md-tab label=”one”> <md-content class=”md-padding”> <h1 class=”md-display-2″>Tab One</h1> </md-content> </md-tab> <md-tab label=”two”> <md-content class=”md-padding”> <h1 class=”md-display-2″>Tab Two</h1> </md-tab> <md-tab label=”three” id=”three”> <md-content class=”md-padding”> <h1 class=”md-display-2″>Tab Three</h1> </md-content> </md-tab> […]

ng-click not working while calling a function on a ‘ul’ in angularJS

I’m creating a navigation menu using angularJS. My ng-click with the function “sayHello()” inside the ul or li are not working. However, all the other ng-click are working fine. ALso, if I just remove ‘obj.showChildMenu = !obj.showChildMenu’ from my first ng-click in the ul and just include ‘sayHello’ there, it is not working. But the one which shows = ‘obj.showChildMenu = !obj.showChildMenu’ seems to work fine. I’ve only attached the sample code here. The controller […]

AngularJS – ui-routing with ng-click not working properly

I’m using ui-router for creating some routes and I’m getting this very weird thing happening. I have this route config .state(‘chapter_route’, { url: ‘/book/:chap’, templateUrl: “views/chapter.html”, params: { chap: null} }) So when I clink on: <a ui-sref=”chapter_route({ chap: getChapter.title})”>CHAPTER:</a> It redirects me, as I wanted, to this following ui-view: <div class=”panel panel-default”> <div class=”panel-body”> <p>{{getChapter.title}}</p> {{getChapter.content}} </div> </div> …… …… <div class=”panel panel-default” data-ng-repeat=”cha in allChapters”> <div class=”panel-body”> <a ui-sref=”chapter_route({ chap: cha.title})” ng-click=”changeChapter(chap)”>{{cha.title}}</a> {{cha.content […]

Call function within object as parameter for a directive

currently I’m extending my application, so I can give a directive (which generates a table grid) an object for additional buttons to show (for adding other other actions). Now I can show the button but I need to execute some code as function which should be apply for a click on that button. The object itself contains strings and function in a mixed way, like this: <tablegrid table=”flavorings” additional-buttons=”[{name: ‘add’, onclick: ‘function(){ }’, icon: ‘fa […]