TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
richard smith
1.5k
285
160.2k
Event Not Firing
Dec 28 2017 3:44 PM
My DoTheWork() event is not firing. Can someone show me how I should re-write so the event fires?
[code]
$scope.matches = [];
$scope.relations = [];
$scope.getAnswer = function($event, choice) {
$scope.picked = choice.question;
$http({
method: "POST",
url: "/LSN/LSA",
dataType: 'json',
data: JSON.stringify(choice),
headers: {
"Content-Type": "application/json"
}
}).then(function(response) {
$scope.items = response.data;
$scope.isnum = response.data[0].isnumeric;
var parentEl = angular.element(document.body);
if ($scope.isnum) {
$mdDialog.show({
parent: parentEl,
scope: $scope,
preserveScope: true,
targetEvent: $event,
disableParentScroll: false,
template: '
' +
'
' +
'
' +
'
' + '
' +
'
' +
'
' +
'
clear
' +
'' +
'
' +
'' +
'
' +
'
' +
'
' +
'
Use
autocomplete
to search for typical answers.
' +
'
'md-selected-item="ctrl.selectedItem" ' +
'md-search-text="ctrl.searchText" ' +
'md-items="item in items" ' +
'md-item-text="item.answer" ' +
'md-min-length="0" ' +
'placeholder="Click to see options" ' +
'md-autofocus> ' +
'
' +
'
{{item.answer}}
' +
' ' +
'' +
'' +
'
' +
'' +
'
' +
'
Complete
' +
'' +
'',
controller: DoTheWork,
controllerAs: 'ctrl'
});
}
function DoTheWork($scope, $mdDialog, $http, sharedData) {
$scope.clickAnswer = function(item) {
var idx = -1;
for (var itr = 0; itr < $scope.matches.length; itr++) {
if ($scope.matches[itr].answer == item.answer) {
idx = itr;
break;
}
}
if (idx > -1) {
$scope.matches.splice(idx, 1);
} else {
$scope.matches.push(item);
}
}
var self = this;
self.cancel = function($event) {
$mdDialog.cancel();
};
self.finish = function($event) {
$mdDialog.hide();
};
$scope.closeDialog = function() {
var sku = sharedData.getSkuItem();
$scope.relations = [];
for (var itr = 0; itr < $scope.matches.length; itr++) {
var relation = {};
relation.id = 0;
relation.s = s.IC;
relation.identifier = choice.identifier;
relation.answer = $scope.matches[itr].answer;
$scope.relations.push(relation);
};
$scope.matches = [];
$http({
method: "POST",
url: "/Lumbda/Rela",
dataType: 'json',
data: JSON.stringify($scope.relations),
}).then(function(response) {
$scope.status = response.data;
}, function(response) {
$scope.error = response.statusText;
alert('Error ' + response.statusText);
});
$mdDialog.hide();
}
}
}, function(response) {
$scope.items = [];
$scope.error = response.statusText;
alert('Error ' + response.statusText);
});
[/code]
Reply
Answers (
1
)
compiler.js:485 Uncaught Error: Template parse errors:
Angular CLI How to Globally define a variable [window.myVar]