Angular JS Development of various pits (continuous update in ... )

Source: Internet
Author: User

    1. The modal of the Angular UI will report the following error when written in the official documentation

var modaldemoctrl = function  ($scope,  $modal,  $log)  {  $ scope.items = [' item1 ',  ' item2 ',  ' item3 '];   $scope. open = function   (size)  {    var modalInstance =  $modal. Open ({       templateUrl:  ' mymodalcontent.html ',       controller:  ModalInstanceCtrl,      size: size,       resolve: {        items: function  ()  {           return  $scope .items;         }      }    });     ModalInstance.result.then (function  (SelectedItem)  {      $ Scope.selected = selecteditem;    }, function  ()  {       $log. info (' modal  dismissed at:  '  + new date ());     });   };};/ / please note that  $modalInstance  represents a modal window  ( Instance)  dependency.// It is not the same as the  $modal   service used above.var modalinstancectrl = function  ($scope,  $modalInstance ,  items)  {   $scope .items = items;   $scope .selected = {     item:  $scope .items[0]  };   $scope .ok = function  ()  {     $modalInstance. Close ($scope. Selected.item);   };  $ scope.cancel = function  ()  {     $modalInstance. Dismiss (' Cancel ');   };};

[$injector: UNPR] Unknown provider: $modalInstanceProvider <-$modalInstance

Google a bit, found that the official has reported a bug

#1549


The official explanation is:

The problem was, were specifying a controller in 2 Places-when opening a modal and inside a template-this is n OT needed. Remove Ng-controller from a template and things would work as expected:

Originally, in writing modal option when the controller has been developed, there is no need to add Ng-controller in the template to make a controller



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.