2
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>    
<script src="angsc.js"></script>
    </head>
    <body>
    <main ng-app="myModule">
        <div ui-view=""></div>
    <main>
       </body>
     </html>

This is my master page

<div ng-controller="myController">  
<input type="button" value="Add" ng-click="addclick()">
<input type="button" value="Search" ng-click="searchclick()">
<br/>
</div>

This is my content page.

var myApp = angular
            .module("myModule",['$mdDialog'])
            .controller("myController",function ($mdDialog,$scope){
                $scope.addclick=function(){
                    $mdDialog.show({
                         template:'addnew.html'
                    }); 
                };
                $scope.searchclick=function(){
                    $mdDialog.show({
                         template:'searchold.html'
                    }); 
                };
            });

This is my js file.                                                                                                                                          I also have 2 html files namely "addnew.html" and "searchold.html". Not getting pop up of those two files on button click. Is there an error in my code? Kindly help me..

3
  • Can you please create fiddle for your question? Commented May 30, 2016 at 10:46
  • Also your closing body tag miss bracket Commented May 30, 2016 at 10:48
  • sorry I dont know creating 2 html page in fiddle..Yeah closed it. still not working.. Commented May 30, 2016 at 10:49

1 Answer 1

1

Your dependent module name is wrong. Instead of $mdDialog it should be ngMaterial. $mdDialog is the service being injected in controller and is part of the ngMaterial module. Change your code as below to get it working:

var myApp = angular
        .module("myModule",['ngMaterial'])
        .controller("myController",function ($mdDialog,$scope){
            $scope.addclick=function(){
                $mdDialog.show({
                     template:'addnew.html'
                }); 
            };
            $scope.searchclick=function(){
                $mdDialog.show({
                     template:'searchold.html'
                }); 
            };
        });

HTML

<html>
 <head>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js">      </script>    
  <script src="angsc.js"></script>
 </head>
 <body>
  <main ng-app="myModule">
    <div ng-controller="myController">  
      <input type="button" value="Add" ng-click="addclick()">
      <input type="button" value="Search" ng-click="searchclick()">
      <br/>
    </div>
  <main>
 </body>
 </html>

Codepen: http://codepen.io/addi90/pen/ZOEqZq

Sign up to request clarification or add additional context in comments.

7 Comments

What is the state configuration you are using? It seems then that there is an issue with the conflict between your state configuration and ng-controller. Please provide the code for state configuration to understand the issue better
You have used ui-view directive from ui-router which needs state configuration. Are you using the states for multiple routes/ views?
I dont think so. I had completely put up the code in my question.
Ok. That is your issue. You should not use ui-view if you don't have state configuration defined. I have updated the html code in my answer and a working codepen for your issue
Hi I would like to ask how to load that addnew.html as popup instead of displaying it?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.