0
votes

I have a problem with my directive template. When execute ionic run android and go to inspect the device (chrome://inspect), it throws Failed to load resource: net::ERR_FILE_NOT_FOUND. But if I write ionic serve, it works correctly. Also works fine if I write the directive code directly in the main html (recetas.html).

enter image description here

The code:

The directive (recetasCardDirective.js):

.directive('recetasCard', function(){

return {
    restrict: 'E',
    templateUrl: "/templates/recetas-card.html",
    scope: {
        titulo: '@',
        img: '@'
    }
}

});

The directive code (recetas-card.html):

<a class="list card estiloCard" href="#/tabs/recetas/{{titulo}}">

  <!-- title card -->
  <ion-item>{{titulo}}</ion-item>

  <!-- img card -->
  <div class="item item-image">
    <img ng-src="data:image/png;base64,{{img}}" class="imgResponsive">
  </div>
  <ion-item class="item-icon-left"> 
    <i class="icon ion-fork"></i>Ver Receta
  </ion-item>
</a>

And where I call directive html (recetas.html):

<ion-view title="Recetas Xpress" id="pag-recetas">

  <ion-content padding="true" class="has-header">

    <div ng-repeat="port in portada">

       <recetas-card titulo={{port.titulo}} img={{port.img}} ></recetas-card>

    </div>

  </ion-content>
</ion-view>

Finally, the config.xml file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.ionicframework.recetasxpress299189" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
  <name>recetasXpress</name>
  <description>
        An Ionic Framework and Cordova project.
    </description>
  <author email="[email protected]" href="http://example.com.com/">
      Your Name Here
    </author>
  <content src="index.html"/>
    <access origin="*"/>
    <access origin="tel:*" launch-external="yes"/>
    <allow-navigation href="*"/>
    <allow-navigation href="http://*/*"/>
    <allow-navigation href="https://*/*"/>
    <allow-navigation href="data:*"/>
    <allow-intent href="*"/>
    <access origin="*"/>
    <preference name="phonegap-version" value="3.7.0" />
  <preference name="webviewbounce" value="false"/>
  <preference name="UIWebViewBounce" value="false"/>
  <preference name="DisallowOverscroll" value="true"/>
  <preference name="SplashScreenDelay" value="2000"/>
  <preference name="FadeSplashScreenDuration" value="2000"/>
  <preference name="android-minSdkVersion" value="16"/>
  <preference name="BackupWebStorage" value="none"/>
  <preference name="SplashScreen" value="screen"/>
  <feature name="StatusBar">
    <param name="ios-package" value="CDVStatusBar" onload="true"/>
  </feature>
  <platform name="ios">
    <splash src="resources\ios\splash\Default-568h@2x~iphone.png" width="640" height="1136"/>
    <splash src="resources\ios\splash\Default-667h.png" width="750" height="1334"/>
    <splash src="resources\ios\splash\Default-736h.png" width="1242" height="2208"/>
    <splash src="resources\ios\splash\Default-Landscape-736h.png" width="2208" height="1242"/>
    <splash src="resources\ios\splash\Default-Landscape@2x~ipad.png" width="2048" height="1536"/>
    <splash src="resources\ios\splash\Default-Landscape~ipad.png" width="1024" height="768"/>
    <splash src="resources\ios\splash\Default-Portrait@2x~ipad.png" width="1536" height="2048"/>
    <splash src="resources\ios\splash\Default-Portrait~ipad.png" width="768" height="1024"/>
    <splash src="resources\ios\splash\Default@2x~iphone.png" width="640" height="960"/>
    <splash src="resources\ios\splash\Default~iphone.png" width="320" height="480"/>
    <icon src="resources\ios\icon\icon.png" width="57" height="57"/>
    <icon src="resources\ios\icon\[email protected]" width="114" height="114"/>
    <icon src="resources\ios\icon\icon-40.png" width="40" height="40"/>
    <icon src="resources\ios\icon\[email protected]" width="80" height="80"/>
    <icon src="resources\ios\icon\[email protected]" width="120" height="120"/>
    <icon src="resources\ios\icon\icon-50.png" width="50" height="50"/>
    <icon src="resources\ios\icon\[email protected]" width="100" height="100"/>
    <icon src="resources\ios\icon\icon-60.png" width="60" height="60"/>
    <icon src="resources\ios\icon\[email protected]" width="120" height="120"/>
    <icon src="resources\ios\icon\[email protected]" width="180" height="180"/>
    <icon src="resources\ios\icon\icon-72.png" width="72" height="72"/>
    <icon src="resources\ios\icon\[email protected]" width="144" height="144"/>
    <icon src="resources\ios\icon\icon-76.png" width="76" height="76"/>
    <icon src="resources\ios\icon\[email protected]" width="152" height="152"/>
    <icon src="resources\ios\icon\[email protected]" width="167" height="167"/>
    <icon src="resources\ios\icon\icon-small.png" width="29" height="29"/>
    <icon src="resources\ios\icon\[email protected]" width="58" height="58"/>
    <icon src="resources\ios\icon\[email protected]" width="87" height="87"/>
  </platform>
  <platform name="android">
    <splash src="resources\android\splash\drawable-land-ldpi-screen.png" density="land-ldpi"/>
    <splash src="resources\android\splash\drawable-land-mdpi-screen.png" density="land-mdpi"/>
    <splash src="resources\android\splash\drawable-land-hdpi-screen.png" density="land-hdpi"/>
    <splash src="resources\android\splash\drawable-land-xhdpi-screen.png" density="land-xhdpi"/>
    <splash src="resources\android\splash\drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/>
    <splash src="resources\android\splash\drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/>
    <splash src="resources\android\splash\drawable-port-ldpi-screen.png" density="port-ldpi"/>
    <splash src="resources\android\splash\drawable-port-mdpi-screen.png" density="port-mdpi"/>
    <splash src="resources\android\splash\drawable-port-hdpi-screen.png" density="port-hdpi"/>
    <splash src="resources\android\splash\drawable-port-xhdpi-screen.png" density="port-xhdpi"/>
    <splash src="resources\android\splash\drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/>
    <splash src="resources\android\splash\drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/>
    <icon src="resources\android\icon\drawable-ldpi-icon.png" density="ldpi"/>
    <icon src="resources\android\icon\drawable-mdpi-icon.png" density="mdpi"/>
    <icon src="resources\android\icon\drawable-hdpi-icon.png" density="hdpi"/>
    <icon src="resources\android\icon\drawable-xhdpi-icon.png" density="xhdpi"/>
    <icon src="resources\android\icon\drawable-xxhdpi-icon.png" density="xxhdpi"/>
    <icon src="resources\android\icon\drawable-xxxhdpi-icon.png" density="xxxhdpi"/>
  </platform>
  <icon src="resources\android\icon\drawable-xhdpi-icon.png"/>
  <allow-navigation href="http://192.168.1.42:8100"/>
</widget>

Don't know what can I do... Thanks in advance and Sorry for my bad english

1

1 Answers

0
votes

Sorry for bothers... The problem was a simply bar in directive.js

The correction (templateUrl):

.directive('recetasCard', function(){

return {
    restrict: 'E',
    templateUrl: "templates/recetas-card.html",
    scope: {
        titulo: '@',
        img: '@'
    }
}

});

So stupid... Thanks.