JavaScript $mdDialog.prompt throws exception, but the function works fine with confirm

For some reason, my prompt dialog stopped working in my yo angular fullstack application.

I googled a solution telling me to update my angular, which i did, but it did not solve the problem.

$scope.showPrompt = function(ev, ret, value) {
  var confirm = $mdDialog.prompt()
  .title('Rediger ' + value)
  .textContent('Indtast en ny værdi for: ' + value)
  .placeholder('getValue()')
  .ariaLabel('Ny ' + value)
  .targetEvent(ev)
  .ok('Accepter')
  .cancel('Annuller');
$mdDialog.show(confirm).then(function(result) {
  //setValue(result);
});
};

Whenever i call the function, i get an error saying TypeError: $mdDialog.prompt is not a function.

If i change the dialog to a .confirm and remove the placeholder it works fine

Answer:1

Edit: In javascript a variable as function is defined at runtime :

//This code throw an error
getValue();
var getValue = function(){};

You have to declare your variable function before calling it :

//Ok
var getValue = function(){};
getValue();

You could also write something like

//Ok because code block is parsed before runtime
getValue();
function getValue(){};

So here your plunker edited https://plnkr.co/edit/YqeyaLqW2B6xn4VHcVlQ?p=preview

Answer:2

What are the differences and similarities between QML and Javascript? I am doing research on it, as I will probably give of a small presentation about QML soon. I have already looked at it on ...

What are the differences and similarities between QML and Javascript? I am doing research on it, as I will probably give of a small presentation about QML soon. I have already looked at it on ...

  1. javascript closed function
  2. javascript closed source
  3. javascript closed window
  4. javascript closed interval
  5. javascript closure variable
  6. javascript closed class
  7. closedoc javascript
  8. javascript window closed event
  9. javascript open closed principle
  10. javascript window.closed not working
  11. javascript websocket closed
  12. acrobat javascript closedoc
  13. javascript tab closed
  14. javascript reopen closed window
  15. javascript browser closed
  16. javascript popup closed
  17. javascript window closed property
  18. javascript browser closed event
  19. javascript page closed
  20. javascript page closed event

I currently have a program running that sends an OpenCV to my Node server by sending the matrix values along with the number of rows and columns. I want to base64 encode this image on the Node server ...

I currently have a program running that sends an OpenCV to my Node server by sending the matrix values along with the number of rows and columns. I want to base64 encode this image on the Node server ...

  1. opencv encode image
  2. opencv encode image jpg
  3. opencv encode image png
  4. base64 encode opencv image
  5. python opencv encode image

I have this game board that stores the results of a tournament, and I can't figure out why the data (the game results being entered in through drop-down menu) gets erased when the browser is closed. ...

I have this game board that stores the results of a tournament, and I can't figure out why the data (the game results being entered in through drop-down menu) gets erased when the browser is closed. ...

  1. data being erased

I am trying to get a variable ($total_news_array, which contains an array of different news items by title, time posted, etc) from a PHP file into a JS one. I have the following code in my JS file: $(...

I am trying to get a variable ($total_news_array, which contains an array of different news items by title, time posted, etc) from a PHP file into a JS one. I have the following code in my JS file: $(...

  1. json parse json stringify
  2. json parse json array
  3. json parse json file
  4. json parse json stringify deep copy
  5. json parse json string
  6. json parse json object
  7. json.parse(json.stringify(obj))
  8. json.parse(json.stringify(data))
  9. json.parse(json.stringify(object))
  10. json parse json
  11. json.parse json array javascript
  12. json.parse json is undefined
  13. json parse json array java
  14. json parse json python
  15. json parse json.net
  16. json_parse json-c
  17. json parse json string c#
  18. json u003d json.parse(data)
  19. json u003d json.parse(this.responsetext)
  20. json_decode(json_encode